I'm creating an excel sheet using openpyxl. Some cells represent monetary values. How can I change the format of a cell to be of type "currency", i.e. I want a "€" symbol to be displayed after the number.
Set openpyxl cell format to currency
why not save it as unicode string? –
Spoken
actually, this was the workaround I'm using at the moment. However, I feel it is cleaner to add the semantic information to the cell, that I could still use it for calculation in excel if needed. –
Musket
Try setting the format code with your desired format code
_cell.number_format = '#,##0.00€'
your code didn't work for me out of the box, but it guided me to the solution.
_cell.number_format = '#,##0.00€'
did the trick. Thank you! –
Musket That was the older API. We changed in recent versions to make it simpler to use. –
Jasik
@Musket where exactly is the difference between your code and the accepted answer? –
Samathasamau
@Samathasamau There is no difference. There was a difference before the edit. –
Madwort
Also, if you have any problem using other than 4 currencies mention on here you can also put your currencies according to excel
example:
Russian Ruble: ₽ #,##0.00
Indonesian Rupiah Rp #,##0.00
this is based on @absolutelyNoWarranty answer
© 2022 - 2025 — McMap. All rights reserved.