How copy entire sheet from one excel sheet to another excel sheet.

11,675 views
Skip to first unread message

samo...@gmail.com

unread,
Apr 17, 2015, 10:47:18 AM4/17/15
to openpyx...@googlegroups.com
Hi,

I am using Opepyxl for one of my project. Now I have a situation to copy entire sheet to another excel sheet. 

How can we do this openpyxl. Can any body help me highlevel on how to achieve this.

Thanks,
Guru

Charlie Clark

unread,
Apr 17, 2015, 11:06:39 AM4/17/15
to openpyx...@googlegroups.com
There is no easy way to do this. You can look at
https://bitbucket.org/openpyxl/openpyxl/issue/171/copy-worksheet-function
for some hints on how to do it.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226

Chris Withers

unread,
Apr 17, 2015, 11:08:34 AM4/17/15
to openpyx...@googlegroups.com
On 17/04/2015 16:06, Charlie Clark wrote:
> Am .04.2015, 16:47 Uhr, schrieb <samo...@gmail.com>:
>
>> Hi,
>> I am using Opepyxl for one of my project. Now I have a situation to copy
>> entire sheet to another excel sheet.
>> How can we do this openpyxl. Can any body help me highlevel on how to
>> achieve this.
>
> There is no easy way to do this. You can look at
> https://bitbucket.org/openpyxl/openpyxl/issue/171/copy-worksheet-function
> for some hints on how to do it.

xlutils.filter also provides a good approach, it's usable as-is if you
xlrd/xlwt are okay for you...

cheers,

Chris

joo...@gmail.com

unread,
Feb 22, 2017, 4:50:45 AM2/22/17
to openpyxl-users, samo...@gmail.com
Does it have to be a copy?  Can it be simply create a new workbook for each sheet?
Message has been deleted

vhud...@gmail.com

unread,
Mar 2, 2017, 10:22:14 PM3/2/17
to openpyxl-users, samo...@gmail.com
Since OP's post the copy functionality has been added(since openpyxl2.4).
https://openpyxl.readthedocs.io/en/default/tutorial.html
source = wb.active
target
= wb.copy_worksheet(source)

so as an example:
ws = wb.active
ws2
= wb.copy_worksheet(ws)
will make worksheet 2 a copy of worksheet 1.
Reply all
Reply to author
Forward
0 new messages