Xml openpyxl不可读内容
使用openpyxl时,如果我更新单元格样式,如下所示:Xml openpyxl不可读内容,xml,excel,python-2.7,openpyxl,Xml,Excel,Python 2.7,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"?> -<recov
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>
除了直接更新类实例中的属性外,还有其他方法更新单元格样式吗
当我在阅读文档时,它说要使用:
ft = Font(color=colors.RED)
a1.font = ft
但这给了我一个属性错误:
AttributeError: 'Cell' object has no attribute 'font'
我不能在没有看到的情况下谈论这个文件,但是可以随意提交一个带有示例文件和创建它的脚本的bug报告。如果您正在编辑一个现有的文件,那么这个错误几乎肯定与openpyxl没有保留的内容有关
但是,
cell.font=font(…)
不起作用这一事实表明,该库的版本相当旧。我建议你用pip install-U--pre
更新到2.3-b2版本,叶意识到我有一个老版本,更新到最新版本,现在可以工作了!谢谢
AttributeError: 'Cell' object has no attribute 'font'