Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Bug: Worksheet.write_comment generates bad comment after calling Worksheet.set_column #45
Firstly, thank you all for this great tool!
I'm using XlsxWriter and I have encountered a problem. I'd like to add comment to some data cells, but found that all the comments cannot display correctly in MS Excel.
I am using Python 2.7.5 and XlsxWriter 0.4.2, on Windows 8 x64 system. My MS Excel is Excel 2013.
Here is some code that demonstrates the problem:
import xlsxwriter workbook = xlsxwriter.Workbook('try_comment.xlsx') worksheet1 = workbook.add_worksheet() worksheet1.write_comment('A1', 'this comment will be good') worksheet1.set_column('B:B', 8.43) worksheet2 = workbook.add_worksheet() worksheet2.set_column('B:B', 8.43) worksheet2.write_comment('A1', 'this comment cannot display correctly in Excel') workbook.close()
When I open the output file
I had a quick look at this and it looks like there are some float values in the xlsx file where Excel expects integers.
If you want to fix this locally while waiting for a new release then you can modify the following function in
def _write_anchor(self, vertices): # Write the <x:Anchor> element. (col_start, row_start, x1, y1, col_end, row_end, x2, y2) = vertices[:8] strings = [col_start, x1, row_start, y1, col_end, x2, row_end, y2] strings = [str(i) for i in strings] data = ", ".join(strings) self._xml_data_element('x:Anchor', data)
And change the second list comprehension to the following:
strings = [str(int(i)) for i in strings]
I'll write some tests and put in a proper fix later.