Reputation: 31
I have started using xlwings to create an excel tool which calls a python code. I think it is super useful and at the same time user-friendly as everybody is used to have excel as GUI.
Now to my problem: The tool works well. However, I am left with some formatting. Currently I am able to do some formatting (range(XX).number_format = XX ), but I have not managed to create my desired format.
I want to have comma separated numbers without decimals.
sht = xw.Book.caller().sheets[0]
sht.range('C:D').number_format = '0.00' (1)
sht.range('C:D').number_format = 'General' (2)
sht.range('C:D').number_format = '#’##0' (3)
(1): This works. However, numbers are not comma separated (as expected)
(2): Does not work. Python runs and runs, nothing happens. (same for 'Number')
(3): Produces desired results on my machine/ my excel version. However, on my friend's excel it looks different and does not produce the desired results anymore.
Thanks a lot in advance for your help.
Upvotes: 3
Views: 11670
Reputation: 35
In order to display the format in thousands and seperate by comma, I tried this,
number_format = "#,##0"
and it works perfectly in my case.
Upvotes: 0