Set the currency symbol when writing with xlsxwriter

Try something like the following:

import xlsxwriter

workbook = xlsxwriter.Workbook('money_format.xlsx')
worksheet = workbook.add_worksheet()

money_format = workbook.add_format({'num_format': '[$R]#,##0.00'})

worksheet.write('A1', 1234.56, money_format)

workbook.close()

The best way to determine the number format that you need is to format the cell in Excel and then edit it and look at what the custom format is.

It may be something like [$R-431]#,##0.00 or something quite complicated if positive and negative values are handled differently.

Update: See also the Number Format Categories section of the XlsxWriter Format docs.


Please try:

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

format.set_num_format()