Python xlwt创建错误的excel书 [英] Python xlwt create faulty excel book
问题描述
我试图使用 xlwt
创建一个带有多个选项卡的输出文件(.xlsx格式)。我的Python的版本号是2.7,我使用的是Aptana Studio 3作为IDE。
I am trying to use xlwt
to create a output file (in .xlsx format) with multiple tabs. The version number of my Python is 2.7, and I am using Aptana Studio 3 as IDE.
我使用了 xlwt
包之前,用相同的环境,执行相同的任务。它运行良好但是这一次,它起初很好,那么突然之后,输出文件变得有问题,无法被MS Excel打开。
I've used the xlwt
package before, with the same environment, to carry out the same task. It worked well. But this time, it works well at first, then suddenly, the output file became faulty that cannot be opened by MS Excel.
这是一个可能有帮助的线索。我的Aptana Studio 3决定在自己的编辑器中打开 .xlsx
,而不是启动MS Excel。虽然这是发生在问题之前,我想知道它是否相关。
Here is a clue that might be helpful. My Aptana Studio 3 decide to open .xlsx
in its own editor rather than start MS Excel. Although this happens before the problem, I am wondering if it is related.
当在Aptana3中打开文件时,文件看起来很正常,但是当我关闭它并打开它使用MS Excel,弹出错误:Excel无法打开文件output.xlsx,因为文件格式或文件扩展名无效验证文件未被损坏,文件扩展名匹配文件的格式。
The file looks normal when it is opened in Aptana3, but when I closed it, and open it with MS Excel, an error pops up:"Excel cannot open the file "output.xlsx" because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
我可以知道如何解决这个问题吗?欢迎任何建议。谢谢。
May I know how I can get over this? Any suggestions are welcome. Thanks.
推荐答案
xlwt
模块无法创建 .xlsx
文件。它是 .xls
文件的作者。
The xlwt
module cannot create .xlsx
files. It is a writer for .xls
files.
警告是由于较新版本的Excel中的一项功能扩展硬化这意味着文件扩展名必须匹配文件类型。
The warning is due to a feature in newer versions of Excel called "extension hardening" which means that the file extension has to match the file type.
如果将程序中的输出文件扩展名更改为 .xls
警告应该消失,Excel会读取文件。
If you change the output file extension in your program to .xls
the warning should go away and Excel will read the file.
这篇关于Python xlwt创建错误的excel书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!