New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Worksheet.write_comment generates bad comment after calling Worksheet.set_column #45

Closed
calfzhou opened this Issue Sep 11, 2013 · 4 comments

Comments

2 participants
@calfzhou

calfzhou commented Sep 11, 2013

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 try_comment.xlsx in MS Excel, the comment in the 1st sheet looks normal and good, but the comment in the 2nd sheet looks weird. See this screenshot:

image

@ghost ghost assigned jmcnamara Sep 11, 2013

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Sep 11, 2013

Owner

Hi @calfzhou

Thanks for the very clear and detailed bug report.

That is definitely a bug. I'll look into it in the next few days.

John

Owner

jmcnamara commented Sep 11, 2013

Hi @calfzhou

Thanks for the very clear and detailed bug report.

That is definitely a bug. I'll look into it in the next few days.

John

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Sep 11, 2013

Owner

@calfzhou

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 vml.py:

    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.

Owner

jmcnamara commented Sep 11, 2013

@calfzhou

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 vml.py:

    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.

@calfzhou

This comment has been minimized.

Show comment
Hide comment
@calfzhou

calfzhou Sep 11, 2013

Thank you @jmcnamara for such a quick response!

calfzhou commented Sep 11, 2013

Thank you @jmcnamara for such a quick response!

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Sep 12, 2013

Owner

Fixed in version 0.4.3 on PyPI.

Thanks for the bug report.

John

Owner

jmcnamara commented Sep 12, 2013

Fixed in version 0.4.3 on PyPI.

Thanks for the bug report.

John

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment