ZJS*_*ZJS 3 python excel xlsxwriter
当使用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)
Run Code Online (Sandbox Code Playgroud)
您需要设置单元格的格式以指定数字的表示方式:
num_fmt = workbook.add_format({'num_format': '#,###'})
...
sheet.write_number(0, 0, 1000, num_fmt)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3191 次 |
| 最近记录: |