我正在尝试使用 Python 在 Excel 文件中添加美元符号 ($)。我已将数字格式编码为'"$"#,##0.00'
(参见下面的代码)。
我运行代码并下载 Excel 文件。但是当我打开 Excel 文件时,它会显示英镑符号。
请注意:我的默认会计格式符号是“£ English UK”。我需要将货币符号显示为$
使用 Python。如何?
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"'
wb.save(self.response.out)