如何生成xls&在C#中以编程方式从Office 2003 xml电子表格中获取xlsx [英] How to generate xls & xlsx from office 2003 xml spreadsheet programatically in c#

查看:63
本文介绍了如何生成xls&在C#中以编程方式从Office 2003 xml电子表格中获取xlsx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我们的应用程序在服务器中将大数据导出为Office 2003 xml电子表格格式.用户可以下载xml文件.可以轻松地在Office 03和07中正确打开该文件.我想知道是否可以从服务器中的该xml文件创建xls和xlsx格式并将其提供给用户吗?

[服务器没有办公室,也没有办公室.因此,互操作在这种情况下是没有用的.]

======编辑=====

不能使用第三方解决方案...:(

解决方案

如果我正确地理解了您的问题,那么您不仅在提供纯" XML,而且还提供了SpreadsheetML,它被Excel解释为二进制的普通Excel文件.格式.因此,您的用户已经有了一个非常好的解决方案.您如何创建这些文件?我使用XSLT将我的XML数据转换为SpreadsheetML,而SpreadsheetML只是一种特定的XML格式.这样,我可以做Excel中可能做的所有事情(格式,公式等).它不仅仅是将XML转换为CSV.

您为什么要更改此设置?我可以看到生成的XML-Excel文件通常很大,是原因吗?

现在,由于Excel 2007格式(xlsx)基本上是描述该文件的结构和数据的一些XML文件的zip归档文件-只需将任何xlsx的文件扩展名重命名为zip并提取后进行检查--您可能能够适应现有的解决方案,即,无需创建一个SpreadsheetML-(XML)File,而是创建多个SpreadsheetML-(XML)File,然后将其打包/压缩到服务器中.我认为您的常规服务器安装应具有必要的工具.

但是,此解决方案难以维护(您可能会使用当前的解决方案,如果我没问题的话),并且更改XSLT以添加新功能需要相当多的知识.因此,我也再次推荐Aspose.Cells,即使是一些知识渊博的用户也可以更改简单格式.

HTH安德烈亚斯(Andreas)

Currently our application exporting large data to office 2003 xml spreadsheet format in server. The user can download the xml file.The file can be easily opened in office 03 and 07 correctly. I want to know whether it is possible to create xls and xlsx format from this xml file in server and serve them to user?

[The server doesn't have office and neither will be.So interop is useless in this case.]

====== EDIT=====

Can't use third party solutions... :(

解决方案

If I understand your question corretly, you are not just serving 'pure' XML, but SpreadsheetML that is interpreted by Excel just as an ordinary Excel-file in binary format. So your users already have a very nice solution. How do are you creating those files? I use an XSLT to transform my XML-data to SpreadsheetML that is just a specific XML-format. In that way I can do anything that is possible in Excel (formattings, formulas etc.). It yould be much more than just transforming XML to CSV.

Why do you want to change this? I can see that the resulting XML-Excel file usually is huge, is that the reason?

Now, since Excel 2007 format (xlsx) is basically a zip-archive of some XML-files describing the structure and the data of the file -- just rename the file extension name of any xlsx to zip and inspect after extracting -- you might be able to adapt your existing solution, i.e. instead of creating one SpreadsheetML-(XML)File create several and pack/zip them one the server. I assume your normal server installation should have the necessary tools.

BUT - this solution is difficult to maintain (as you might know wiht you current solution -- if I am at all right) and changes in the XSLT to add new functionality requires quite a bit of knowledge. So again I as well can recommend Aspose.Cells, even some knowledgeable users might be able to change simple formats.

HTH Andreas

这篇关于如何生成xls&在C#中以编程方式从Office 2003 xml电子表格中获取xlsx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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