SWT OleClientSite:如何在 Excel 中加载 XML 文件?
我有一个 OfficeML 格式的 Excel 文件 MyData.xls。 由于我从 Office 2003 升级到 Office 2007,我收到一条警告消息,指出文件内容与文件扩展名不匹配。 看来 OfficeML 现在必须具有扩展名“xml”。
在我的应用程序中,我使用 OleClientSite 在 OleFrame 对象中显示文件。 如果我将文件扩展名更改为“xml”,则 Excel 不会启动。 如果我将扩展名保留为“xsl”,则会收到上述警告消息。
如何强制使用 Excel 在 OleFrame 中打开扩展名为“xml”的文件?
I have an Excel file in OfficeML format, MyData.xls. Since I upgraded to Office 2007 from Office 2003 I get a warning message saying that the file content does not match the file extension. It seems that OfficeML now must have the extension 'xml'.
In my application I use OleClientSite to display the file in an OleFrame object. If I change the file extension to 'xml' then Excel is not started. If I leave the extension as 'xsl' then I get the above warning message.
How can I force the file with the 'xml' extension to be opened in the OleFrame using Excel?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
应出现在所使用的 XSL 模板中。
下面的链接清楚地解释了如何包含处理指令。 我必须做类似的事情,它对我有用。
The
<?mso-application progid="Excel.Sheet"?>
should be present in the XSL template used.The below link explains clearly how to include the processing instruction. I had to do something similar and it worked for me.
http://www.shareyourwork.org/roller/ralphsjavablog/entry/generating_excel_sheets_with_xslt
也许我遗漏了一些东西,但是您不应该使用
.xslx
作为您的扩展吗? 我假设通过 OfficeML,您指的是 Office Open XML。Maybe I'm missing something, but shouldn't you just use
.xslx
as your extension? I'm assuming that by OfficeML, you're refering to Office Open XML.最简单的解决方案是切换回 2003 格式,这不需要对您的应用程序进行任何更改。 为此,请打开扩展名为 *.xls 的文件。 当出现警告提示时(“...您想现在打开文件吗?”),继续打开(这是一个警告,以确保您不会无意中打开启用宏的文件)。 在 Excel 中并打开文件后,只需将其另存为 *.xls 即可。 这可以通过转到“Office 按钮/另存为/Excel 97-2003 工作簿”来完成。
现在,更困难的解决方案是升级您的应用程序以处理新的 OfficeML 格式。 我不知道您正在使用的组件,但它可能仍然适用于新标准中的某些二进制部分(尤其是 VBA 项目),但您必须解压并开始读取 XML 文件。
如果您尚未执行此操作,请创建一个新的 Excel 工作簿,将其另存为 *.xlsx(2007 格式),然后在资源管理器中将其扩展名更改为 *.zip。 打开它并环顾四周。 要更深入地了解这些文件,我将开始消化这篇 MSDN 文章。
The easiest solution is to switch back to the 2003 format, which should not require any changes to your application. To do this, open your file with the extension set to *.xls. When prompted with the warning ("... do you want to open the file now?"), proceed to open (this is a warning to make sure you don't unintentionally open a macro-enabled file). Once in Excel and the file is open, simply save it as *.xls. This can be done by going to "Office Button / Save As / Excel 97-2003 Workbook".
Now, the harder solution will be upgrading your application to deal with the new OfficeML format. I don't know about the component you're using, but it will likely still work for some of the binary parts in the new standard (most notably VBA projects), but you're going to have to unpack and start reading XML files.
If you haven't already done this, create a new Excel workbook, save it as *.xlsx (the 2007 format) and in Explorer, change its extension to *.zip. Open it up and take a look around. For more in-depth on the files, I would start digesting this MSDN article.