无法打开使用excelLibrary生成的excel文件 [英] Can't open excel file generated with excelLibrary

查看:659
本文介绍了无法打开使用excelLibrary生成的excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 excelLibrary 以编程方式创建excel文件,但是我收到一个文件格式错误当我尝试在Microsoft Office Excel中打开生成的文件。

I'm using excelLibrary to programatically create excel files but I get a file format error when I try to open the generated files in Microsoft Office Excel.

我看过这已被报告,但仍然没有答案。

I've seen this has been reported but there's still no answer about it.

我使用Office 2010我可以打开任何其他.xls(97-2003文件格式),但是使用excelLibrary生成的。我也尝试过Open Office,仍然无法打开生成的文件。我没有尝试在Office 97-2003中打开它们。

I use Office 2010 and I'm able to open any other .xls (97-2003 file format) but the ones generated with excelLibrary. I've also tried Open Office and still can't open the generated file. I haven't tried to open them in Office 97-2003.

只要尝试示例代码来重现错误。

有没有人找到如何使用库,而不是遇到这个问题? / p>

Have anybody found how to use the library and not run into this problem?

推荐答案

找到解决方案:

string filename = "c:\Test.xls";
Workbook workbook = new Workbook();
Worksheet sheet = new Worksheet("Test")
workbook.Worksheets.Add(sheet)

for(int i = 0;i < 100; i++)
      sheet.Cells[i,0] = new Cell("");

workbook.save(filename);




问题是Office 2010不支持它,除非有
100个以上的单元格填充。

The problem is that Office 2010 doesn't support it unless there are 100 or more Cells Filled.

我的工作是让它在一个for循环中填充100个单元格。
这样就可以得到它的100个单元格,然后它的工作正常。

My work around was to have it fill 100 cells in a for loop with "". That way it gets it's 100 cell count in and then it works just fine.

参考:此处

这篇关于无法打开使用excelLibrary生成的excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆