使用 xlsxwriter 的一系列单元格的单元格格式
Cell Format for a range of cells using xlsxwriter
我正在使用 xlsxwriter 将 pandas 数据帧导出到 excel 文件。我需要在不使用 worksheet.write 函数的情况下格式化一系列单元格,因为数据已经存在于单元格中。
如果我使用 set_row 或 set_column,它会将格式添加到整行或整列。
请帮我找到解决办法。
I need format a range of cells without using worksheet.write function as the data is already present in cells.
一般情况下,XlsxWriter 无法做到这一点。如果要为单元格指定格式,则需要在将数据写入单元格时指定格式。
有些选项可能适合也可能不适合您的需要:
- 行和列格式。但是,这会格式化行或列的其余部分,而不仅仅是包含数据的单元格。
- 通过
add_table()
添加 table 格式。
- 通过
conditional_format()
添加条件格式。
但是,这些只是解决方法。如果您确实需要格式化单元格,则需要在使用 write()
.
时执行此操作
我正在使用 xlsxwriter 将 pandas 数据帧导出到 excel 文件。我需要在不使用 worksheet.write 函数的情况下格式化一系列单元格,因为数据已经存在于单元格中。
如果我使用 set_row 或 set_column,它会将格式添加到整行或整列。 请帮我找到解决办法。
I need format a range of cells without using worksheet.write function as the data is already present in cells.
一般情况下,XlsxWriter 无法做到这一点。如果要为单元格指定格式,则需要在将数据写入单元格时指定格式。
有些选项可能适合也可能不适合您的需要:
- 行和列格式。但是,这会格式化行或列的其余部分,而不仅仅是包含数据的单元格。
- 通过
add_table()
添加 table 格式。 - 通过
conditional_format()
添加条件格式。
但是,这些只是解决方法。如果您确实需要格式化单元格,则需要在使用 write()
.