我真的可以格式化WriteOnlyCell openpyx吗

2024-06-16 13:48:20 发布

您现在位置:Python中文网/ 问答频道 /正文

有谁能告诉我文档-https://openpyxl.readthedocs.io/en/stable/optimized.html是否准确,您是否可以实际格式化WriteOnlyCell

当使用示例代码中的行-cell.font = Font(name='Courier', size=36)时,我收到错误“分配给类槽中未定义的属性'font'”, “来源”:“pylint”

我需要使用只写工作簿wb = Workbook(write_only=True)将数据转储到excel中的多个工作表中

源代码似乎有一个styles属性,但是来自官方文档的示例代码为我抛出了一个错误

来自-https://openpyxl.readthedocs.io/en/2.4/_modules/openpyxl/writer/write_only.html的代码段

styled = cell.has_style

write_cell(xf, self, cell, styled)

if styled: # styled cell or datetime

    cell = WriteOnlyCell(self)     

Tags: 代码文档httpsio示例html错误readthedocs