[英]How to put in the thousands separator in xlsx using xlsxwriter module?
当使用xlsxwriter时,如何让xlsx文件包含列中带逗号格式的数字(而不是字符串)的列?
我想做什么 -将1000变为1,000,同时保留价值作为数字
尝试失败......
#gives warning in cell (asking if it should be a number) + writes as string not number
sheet.write_string(0,0,re.sub("^0*|\.?0*$","",format(val, ',.10f')) )
# writes as number with no warning, but no commas
sheet.write_number(0,0,1000)
您需要设置单元格的格式以指定数字的表示方式:
num_fmt = workbook.add_format({'num_format': '#,###'})
...
sheet.write_number(0, 0, 1000, num_fmt)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.