有谁知道用于创建 Excel 文件的 XSL 库?
我想使用 XSL 创建 Excel 2003 可以打开的 excel .xml 文件。有谁知道我可以用于此目的的 XSL 模板库?
I would like to use XSL to create excel .xml files that Excel 2003 can open. Does anyone know of a XSL template library that I can use for the purpose?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不可能有任何一种通用 XSLT 样式表可以完成这项任务,因为源数据可以以任何可能的奇怪方式设计。
此时您可以采取的最佳方法是了解 Excel 2003 的 XML 格式的架构(下面给出的链接)并编写一个可生成该 XML 的 XSLT。
虽然这可能是一种复杂且错误的方法,但更简单的方法是查看源 XML 数据,然后使用您打算对该信息执行的所有格式手动创建 Excel 工作表,然后将其另存为 XML 。在文本编辑器中打开它,了解 XML 的外观,并编写一个 XSLT,将源 XML 转换为结果 XML。
正如我所说,由于格式可以是您想要的任何内容,并且源 xml 可以是任何内容 - 根本无法设计通用样式表(除非它只是已经存在某些源 xml 标准的数据列 - 我可能不知道)
PS:-如果我根据我使用 Excel XML 的经验正确记得的话,有一些节点或属性必须指定总行数和总列数,如果错误的话,它会在以下情况下抱怨:你打开文件。
希望这有帮助。
There cannot be any one generic XSLT stylesheet that can do this task since the source data can be designed in any strange way possible.
The best approach that you can take at this time is to get to know the Schema's for Excel 2003's XML Format - link given below - and write an XSLT which would generate that XML.
While this could be a complicated and erroneous approach, an easier approach would be to have a look at your source XML data, then creating the Excel sheet manually with all the formatting that you intend to do with that information, and then save it as XML. Open this in a text editor to get an idea of how the XML looks and write an XSLT which would convert your source XML to this resultant XML.
Again as I said, since the formatting could be anything that you could want and the source xml can be anything - a generic stylesheet simply cannot be designed (Unless it is only columns of data for which some source xml standard is already there - which I may not be aware of)
PS:- If I remember correctly from my experience with Excel XML, there was some node or attribute where you had to specify the total number of rows and total number of columns, which if wrong would make it complain when you open the file.
Hope this helps.
这对于您的需求来说可能太简单了,但是您始终可以使用 XSLT 输出制表符或逗号分隔的文本文件,Excel 可以很好地打开该文件。
This may be too simple for your needs, but you can always output a tab- or comma-delimited text file using XSLT, which Excel will open nicely.