Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 292
Niel Avatar asked Sep 17 '15 09:09

Niel


People also ask

What is difference between Openpyxl and Xlsxwriter?

XlsxWriter vs openpyxl: What are the differences? Developers describe XlsxWriter as "A Python module for creating Excel XLSX files". A Python module for creating Excel XLSX files. On the other hand, openpyxl is detailed as "A Python library to read/write Excel 2010 xlsx/xlsm files".

What is Xlsxwriter in Python?

XlsxWriter is a Python module for writing files in the XLSX file format. It can be used to write text, numbers, and formulas to multiple worksheets. Also, it supports features such as formatting, images, charts, page setup, auto filters, conditional formatting and many others.


1 Answers

Please try:

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

format.set_num_format()

like image 168
pnuts Avatar answered Sep 28 '22 09:09

pnuts