【发布时间】:2021-09-17 16:51:56
【问题描述】:
我正在编写 python 脚本,我将一些数据保存在 excel 工作表中。为此,我使用xlsxwriter。我有以下代码:
out_xls_path = os.path.join(dir_path, 'moprime', 'output.xlsx')
workbook = xlsxwriter.Workbook(out_xls_path)
io_sheet = workbook.add_worksheet("Input-Output ()")
io_sheet.set_column(1, 3, 25)
style = workbook.add_format({'bold': True, 'font_name': 'Calibri', 'align': 'center', 'border': 1})
io_sheet.write('C1', "ch/sl spread", style)
io_sheet.write('D1', "{}%".format(chsl_spread), style)
io_sheet.write('C2', "ch/sl spread", style)
io_sheet.write('D2', 23, style)
上面做,下面是excel表格:
我想在D1 中了解如何删除上面写着The number in the cell is formatted as text 的那个小点。谢谢
【问题讨论】:
-
你在这里写文字
"{}%".format(chsl_spread) -
为什么D列有不同的值类型?
-
@Sabil 你应该能够复制它。 “为什么 D 列有不同的值类型”我只是为了测试而这样做,没有什么逻辑。
标签: python excel xlsxwriter