Set openpyxl cell format to currency

18,748

Try setting the format code with your desired format code

_cell.number_format = '#,##0.00€' 
Share:
18,748
Dominic
Author by

Dominic

PHD student in Freiburg, Germany.

Updated on July 23, 2022

Comments

  • Dominic
    Dominic almost 2 years

    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.

  • Dominic
    Dominic over 8 years
    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!
  • Charlie Clark
    Charlie Clark over 8 years
    That was the older API. We changed in recent versions to make it simpler to use.
  • Gigino
    Gigino over 3 years
    @Dominic where exactly is the difference between your code and the accepted answer?
  • Mare Seestern
    Mare Seestern over 2 years
    @Gigino There is no difference. There was a difference before the edit.