打开使用SpreadSheetGear创建的xlsx文件 [英] Opening xlsx file created with SpreadSheetGear

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

问题描述

我已经使用SpreadSheetGear创建了一个简单的Excel文件.如果我将其另存为xls文件

I have created a simple Excel file using SpreadSheetGear. If I save it as an xls file

workbook.SaveAs("file.xls", SpreadsheetGear.FileFormat.Excel8);

并将其附加到电子邮件中,我可以在手机上打开它(已在iPhone和Android上进行了测试).

and attach it to an email, I can open it on my phone (tested both with iPhone and Android).

如果我将其另存为xlsx文件

If I save it as an xlsx file

workbook.SaveAs("file.xlsx", SpreadsheetGear.FileFormat.OpenXMLWorkbook);

并将其附加到电子邮件中,我无法在手机上打开它.

and attach it to an email, I CANNOT open it on my phone.

如果我打开计算机上的xlsx文件附件并将其保存且没有任何更改并附加到电子邮件中,则现在可以在手机上打开它.

If I open the xlsx file attachment on my computer and save it with no changes and attach it to an email, I now can open it on my phone.

显然,Excel保存文件的方式与SSG不同. xlsx文件附件的文件大小为9 KB.当我在计算机上打开并保存它时,新文件大小为24 KB.

Apparently Excel saves the file differently than SSG. The file size of the xlsx file attachment is 9 KB. When I open it on my computer and save it, the new file size is 24 KB.

我的一些用户更喜欢xlsx格式.我有什么办法可以使SSG生成的文件附件像Excel生成的文件附件一样打开?

Some of my users prefer the xlsx format. Is there anything I can do with to make the SSG generated file attachment open like an Excel generated file attachement?

推荐答案

iOS依赖于Open XML文件格式的工作表数据中存在的某些属性来正确解析这些文件. SpreadsheetGear不会写出这些属性,因为在Open XML文件格式规范中将它们列为可选属性,而且如您所指出的,省略它们会减小文件大小.无论出于何种原因,Excel总是会写出这些可选属性,而其他第三方组件则常常依赖于它们的存在才能正常运行. SpreadsheetGear V5添加了一种变通办法,通过启用某些实验"选项来写出这些属性.添加此选项的原因是OLE DB提供程序也表现出这种错误的行为.您可以尝试以下操作,看看这是否有助于SpreadsheetGear与查看器更好地配合使用:

iOS depends on certain attributes being present in the worksheet data of the Open XML file format to properly parse these files. SpreadsheetGear does not write these attributes out because they are listed as optional in the Open XML file format specification and, also, omitting them reduces file size, as you have noted. Excel, for whatever reason, always writes out these optional attributes and other third-party components often times rely on their presence to function correctly. SpreadsheetGear V5 added a workaround to write out these attributes by enabling a certain "Experimental" option. This option was added because the OLE DB provider also exhibits this errant behavior. You might try something like the following and see if this helps in getting SpreadsheetGear to better work with your viewer:

IWorkbookSet workbookSet = Factory.GetWorkbookSet();
workbookSet.Experimental = "OleDbOpenXmlWorkaround";
IWorkbook workbook = workbookSet.Workbooks.Open(@"C:\temp\BadWorkbook.xlsx");
workbook.SaveAs(@"C:\temp\GoodWorkbook.xlsx", FileFormat.OpenXMLWorkbook);

请参阅SpreadsheetGear.IWorkbookSet.实验属性,以获取有关此功能的更多信息.

Please see the SpreadsheetGear.IWorkbookSet.Experimental property for more information on this feature.

据我所知,iOS/Andriod/etc通常还取决于SpreadsheetGear不支持或默认情况下不写出的文件格式中的其他某些可选功能.例如,iOS依靠存储在图表中的数据缓存"来显示图表系列数据点,并且SpreadsheetGear对写出此数据缓存的支持受到限制.这可能导致图表在iOS,Android等系统中无法按预期显示.

From what I can tell, iOS/Andriod/etc often also depend on other certain optional features available in the file formats that SpreadsheetGear either doesn't support or write out by default. For instance, iOS depends on a "data cache" stored within charts to display chart series data points and SpreadsheetGear's support for writing out this data cache is limited. This can result in charts not displaying as expected in iOS, Android, etc.

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

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