Error Message while opening the file:
Excel found unreadable content in zz.xlsx. Do you want to recover the contents of the work book?If you trust the source of the workbook,click Yes.
If I say "Yes" got "Repairs to zz.xlxs" pop up shows.
Could any one please help me. What format of the excel could have caused this. As i tried sample workbook without any formatting it work fine.
My code :
from openpyxl import Workbook
from openpyxl import load_workbook
#open existing workbook
wb = load_workbook(filename = 'xx.xlsx')
wb.save('zz.xlsx')
Run Code Online (Sandbox Code Playgroud)
Appreciate your help. Thanks!
小智 5
首先检查您的文件 *.xlsx 格式是“Office Open XML”还是“来自 Microsoft Excel 2007/2010/2013 的 XML”。如果这是格式,它将正常工作。
默认情况下,该文件不会保存为模板,您可以定义它以尝试是否这是导致错误的原因。 Openpyxl 文档
wb = load_workbook('document.xlsx')
wb.save('document_template.xltx', as_template=False)
Run Code Online (Sandbox Code Playgroud)
您可以尝试验证使用 MS Office OpenXML 生产力工具创建的文件,但前提是该文件是在安装了 lxml 的计算机上创建的。否则,请使用您实际用于创建文件的脚本提交错误。
| 归档时间: |
|
| 查看次数: |
34315 次 |
| 最近记录: |