jmcnamara / XlsxWriter

A Python module for creating Excel XLSX files.
https://xlsxwriter.readthedocs.io
BSD 2-Clause "Simplified" License
3.65k stars 633 forks source link

Column format disappears after inserting data #226

Closed mamcgree closed 9 years ago

mamcgree commented 9 years ago

Greetings John..

When I format a column and then write a cell the formatting disappears for all cells above that cell. The following example with demonstrate.

import xlsxwriter

workbook = xlsxwriter.Workbook('demo.xlsx')
worksheet = workbook.add_worksheet()
format = workbook.add_format({'bottom':1,'bg_color':'yellow'})

worksheet.set_column(0, 0, 10 , format)
worksheet.write(10, 0, 'test')

workbook.close()

Thank you in advance..

Mark..

jmcnamara commented 9 years ago

Hi Mark,

Thanks for the report and working example.

I don't see the formatting disappearing, see the output below from your program, and technically there isn't anything that would make that happen. What version of Excel are you using?

screenshot

John

mamcgree commented 9 years ago

Hi John..

Thanks for the quick reply.. I am opening it up in Libre Office and this is what I get. Not sure why it is different.. Python 2.7.6 Libre office 4.2.7.2 xlswriter version = '0.6.7'

Let me know what you think.

Thanks again..

Mark

jmcnamara commented 9 years ago

Let me know what you think.

I think this is most likely a LibreOffice issue. I see it with LibreOffice 4.1.0.4 as well.

Also, I also see it with files created in Excel. For example, here is a new file created in Excel 2011 for Mac:

screenshot

And here is the same file in LibreOffice 4.1.0.4:

screenshot

So this doesn't look like an XlsxWriter issue.

John

mamcgree commented 9 years ago

Thanks John..

I tried many workarounds and never thought to try it in MS Excel.. BTW really love your xlsxwriter.. Used it many times in perl but thought it would be faster and more efficient in Python so I'm making the switch.

Cheers..

jmcnamara commented 9 years ago

I just upgraded to LibreOffice 4.4.1.2. The cells below the text show formatting but the cells above still don't.

Used it many times in perl but thought it would be faster and more efficient in Python so I'm making the switch.

The Perl and XlsxWriter versions should perform about the same. Depending on the version of Python/Perl, CPU, Memory, HD/SSD one might be slightly faster than the other but overall they should be the same.

Nevertheless, use whichever one gets the job done. :-)

Regards,

John