0
当使用openpyxl,如果我更新细胞像这样的风格:openpyxl无法读取内容
wb = Workbook()
ws = wb.active
a1 = ws['a1']
al.value = 'Hello World!'
a1.style.font.name = 'Algerian'
打开在Excel文件给出了一个错误:
“的Excel发现无法读取内容......”
日志文件:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<logFileName>error107840_01.xml</logFileName>
<summary>Errors were detected in file 'D:\Phocas\Phocas-Automation\test.xlsx'</summary>
-<removedRecords summary="Following is a list of removed records:">
<removedRecord>Removed Records: Cell information from /xl/worksheets/sheet1.xml part</removedRecord>
</removedRecords>
</recoveryLog>
细胞显示正确的样式(font.name =阿尔及利亚),但吨将文件分发给用户时,他错误消息是不可取的。这也仅仅是个例子,我得到了同样的问题,如果我尝试类似:
a1.style.font.bold = True
有一些其他的方法来更新不是直接更新的类实例的属性之外的单元格样式?
当我https://openpyxl.readthedocs.org/en/latest/usage.html阅读文档,它说的使用方法:
ft = Font(color=colors.RED)
a1.font = ft
但是这给了我一个属性错误:
AttributeError: 'Cell' object has no attribute 'font'
叶认识到我有一种方式旧版本和更新到最新,现在工作!谢谢。 –