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

Issue with Center Across Property #381

Closed
zhangallan opened this Issue Sep 20, 2016 · 2 comments

Comments

2 participants
@zhangallan

Hi John,

First I'd like to thank you for a wonderful package. It's making my life much easier! I have what I think is a small bug, but it might also be an issue with the documentation:

Setting the center_across property in a cell format causes an Exception because xlsxwriter tries to convert the property into the set_center_across method and fails as set_center_across doesn't accept any arguments. Judging from commit 32db5c0, there was a fix to the method, but that broke the way of setting it as a property. The documentation I'm referring to is here: http://xlsxwriter.readthedocs.io/format.html under "Format methods and Format properties".

From what I can tell, you may only be allowed to set center across through the align property as of the current version or something like that.

I am using Python version 3.5.2 and XlsxWriter 0.9.3.

Here is some code that demonstrates the problem:

import xlsxwriter

workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

format = workbook.add_format({"center_across": True})

worksheet.write('A1', 'Hello world', cell_format = format)

workbook.close()
@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Sep 20, 2016

Owner

Thanks for the report. That looks like a bug.

For now use the center_across() method explicitly:

import xlsxwriter

workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

format = workbook.add_format()
format.set_center_across()

worksheet.write('A1', 'Hello world', format)

workbook.close()

Or set it via the align property:

import xlsxwriter

workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

format = workbook.add_format({'align': 'center_across'})

worksheet.write('A1', 'Hello world', format)

workbook.close()
Owner

jmcnamara commented Sep 20, 2016

Thanks for the report. That looks like a bug.

For now use the center_across() method explicitly:

import xlsxwriter

workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

format = workbook.add_format()
format.set_center_across()

worksheet.write('A1', 'Hello world', format)

workbook.close()

Or set it via the align property:

import xlsxwriter

workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

format = workbook.add_format({'align': 'center_across'})

worksheet.write('A1', 'Hello world', format)

workbook.close()

@jmcnamara jmcnamara added the bug label Sep 20, 2016

@jmcnamara jmcnamara self-assigned this Sep 20, 2016

jmcnamara added a commit that referenced this issue Dec 2, 2016

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Dec 2, 2016

Owner

Fixed in version 0.94.

Owner

jmcnamara commented Dec 2, 2016

Fixed in version 0.94.

@jmcnamara jmcnamara closed this Dec 2, 2016

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