Take the 2-minute tour ×

I'm trying to add '$' Symbol in Excel file using python. I have code the number format as :'"$"#,##0.00' (Code below).

Run the code and Download the Excel file. But When i open the excel file it shows pound symbol.

Please note: My default accounting format symbol is "£ English UK". I Need to Show the Currency symbol as $ using python. How ?

    wb = Workbook()
    ws0 = wb.add_sheet('Sheet 1')

    currency_style = XFStyle()        
    currency_style.num_format_str =  '"$"#,##0.00'

    for i in range(1,5):           
        ws0.write(i, 0, 125.05, currency_style) 

    self.response.headers['Content-Type'] = 'application/ms-excel'
    self.response.headers['Content-Transfer-Encoding'] = 'Binary'
    self.response.headers['Content-disposition'] = 'attachment; filename="myfile.xls"'
share|improve this question

2 Answers 2

This code works fine. The problem is with your default accounting format symbol. If it is set to the pound symbol, your worksheet will replace the dollar symbol with the pound when you open the file. You will need to change this setting for it to show the dollar symbol.

share|improve this answer
But Many users are using this . So this is not a solution for this. :( It should be fixed using python itself. –  NNJ Nov 2 '11 at 9:10
@NijinNarayanan Tell me what exactly you need to do with this excel file. How are you opening it ? What is your scenario? –  unni Nov 2 '11 at 9:26
Using this application users can generate and Download the Stock as excel format. In that file all the Prices are in $. So i need to Show all the price in $. –  NNJ Nov 2 '11 at 9:35
@NijinNarayanan I ran your code above and the file file it generated contained $ symbol. I was able to read it just fine –  unni Nov 2 '11 at 9:38
Okey unni. I also got the same. but my client got the Pound symbol and "Rs." and instead of Dollar symbol. Their Default account symbol is Pound and "Rs". I cant able to said to them to change their Excel accounting format. –  NNJ Nov 2 '11 at 9:48

You need to figure out how Excel handles multiple currency symbols, then you can worry about how to use the same solution from python. Might be as simple as escaping the $ in your format, who knows? This might point you in the right direction:



share|improve this answer

Your Answer


