Reputation: 664
I use xlsxwriter to write and apply number format on .xlsx files.
The problem I got is:
After the xlsx file is written, I use the Excel to open it and want to change the number format of the number like clicking the "Comma style" button on Excel
However, the number format in the "Insert Function" is changed, but the display number on cell doesn't change.
In other words, I set the format by xlsxwriter and want to change the format by excel but fail.
Like following screenshot:
I use xlsxwriter to write number format '#,##0' to the cell, so the cell displays is 7.
num_format = workbook.add_format({'num_format': '#,##0', 'align': 'center'})
option = {'type': 'no_blanks', 'format': num_format}
sheet.conditional_format(start_row, start_col, end_row, end_col, option)
And I open the xlsx file on Excel and want to change the format to Percentage(by click % button on Excel) but fail.
Weird thing is the insert function display percentage, but the cell still display 7.
Do I miss any option for the formatting when using xlsxwriter?
Maybe some default setting of xlsxwriter format lock the cell display?
Upvotes: 2
Views: 875
Reputation: 81
Old question, but the issue is probably that you're applying the number format through conditional formatting. (I assume you've made it so that it's always "true".) To be able to change the number format you'll need to turn off or alter the conditional formatting.
Upvotes: 1