Search code examples
pythonexcelcurrencynumber-formattingxlsxwriter

Set the currency symbol when writing with xlsxwriter


I'm having trouble writing the currency symbol I want in my currency values with xlsxwriter.

I followed the tutorial here and I'm able to write out currency values with the correct formatting and a dollar sign (whether this is from the tutorial or excel's default settings I'm not sure).

This works:

money = workbook.add_format({'num_format':'$#,##0.00'})

And it prints out a currency value with the dollar sign.

$1,000.00

But if I try to insert my own currency, let's say R:

money = workbook.add_format({'num_format':'R#,##0.00'})

I get this:

R1000

How can I set the currency symbol using xlsxwriter?


Solution

  • Please try:

    num_format('"R" #,##0.00')  
    

    format.set_num_format()