losing cell style when using xlutils.copy

2,280 views
Skip to first unread message

lzantal

unread,
Jun 15, 2011, 5:09:03 PM6/15/11
to python-excel
Hi,

I have a base spreadsheet file with image and header row color.
When I am using the copy function from xlutils and save the workbook
the image and the style are gone.
How could I copy over the styles? Here is the code I use for copying
'''
import xlrd, xlwt
from xlutils.copy import copy

cb = xlrd.open_workbook('test.xls', on_demand=True)
nb = copy(cb)
# add some values to it
nb.save('test_new.xls')
'''

Thank you

lzantal

Michael Jugovich

unread,
Jun 15, 2011, 6:26:07 PM6/15/11
to python...@googlegroups.com
Try:

cb = xlrd.open_workbook('test.xls', on_demand=True, formatting_info = True)



--
You received this message because you are subscribed to the Google Groups "python-excel" group.
To post to this group, send an email to python...@googlegroups.com.
To unsubscribe from this group, send email to python-excel...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/python-excel?hl=en-GB.


John Machin

unread,
Jun 15, 2011, 6:28:34 PM6/15/11
to python...@googlegroups.com

Losing styles: Read the xlrd docs on open_workbook(). Go to www.python-excel.org, get the tutorial (link near the bottom of the page), read page 48.

Losing image: xlutild.copy.copy() doesn't copy images.

lzantal

unread,
Jun 15, 2011, 7:07:03 PM6/15/11
to python-excel
Hi,

On Jun 15, 3:26 pm, Michael Jugovich <jugov...@gmail.com> wrote:
> Try:
>
> cb = xlrd.open_workbook('test.xls', on_demand=True, formatting_info = True)
>

That did the trick for the cell style.

Thank you

Laszlo

lzantal

unread,
Jun 15, 2011, 7:09:20 PM6/15/11
to python-excel
Hi,

On Jun 15, 3:28 pm, John Machin <sjmac...@lexicon.net> wrote:
> On Thursday, 16 June 2011 07:09:03 UTC+10, lzantal wrote:
>
> > I have a base spreadsheet file with image and header row color.
> > When I am using the copy function from xlutils and save the workbook
> > the image and the style are gone.
> > How could I copy over the styles? Here is the code I use for copying
> > '''
> > import xlrd, xlwt
> > from xlutils.copy import copy
>
> > cb = xlrd.open_workbook('test.xls', on_demand=True)
> > nb = copy(cb)
> > # add some values to it
> > nb.save('test_new.xls')
> > '''
>
> Losing styles: Read the xlrd docs on open_workbook(). Go towww.python-excel.org, get the tutorial (link near the bottom of the page),
> read page 48.
>
> Losing image: xlutild.copy.copy() doesn't copy images.

Thank you.
Cell styles are coming over now.
Unfortunately according to that page the formulas are also not copied
over.
Would a custom filter be able to copy formulas and images over, or is
it a no go?

Thank you again

lzantal


John Machin

unread,
Jun 15, 2011, 8:57:32 PM6/15/11
to python...@googlegroups.com

Unfortunately according to that page the formulas are also not copied
over.
Would a custom filter be able to copy formulas and images over, or is
it a no go?

It's a no go.

Laszlo Antal

unread,
Jun 15, 2011, 9:13:00 PM6/15/11
to python...@googlegroups.com, python...@googlegroups.com
Hi,
Thank you for your fast reply.

lzantal

--
You received this message because you are subscribed to the Google Groups "python-excel" group.
To view this discussion on the web visit https://groups.google.com/d/msg/python-excel/-/mYrNR3O_GNAJ.

Jai Balani

unread,
Jun 16, 2013, 2:24:03 PM6/16/13
to python...@googlegroups.com
Hello John,

Have you come across an alternate to xlutils.copy.copy() that does copy excel images?

Thanks,
Jai
Reply all
Reply to author
Forward
0 new messages