使用样式表将Excel数据转换为XML

时间:2020-12-26 16:33:02

Is there a way to create a kind of "template" in Excel (2010) to take in data in one or more spreadsheets, and then convert that data to XML, based on an XML schema? Or any similar features in Excel?

有没有办法在Excel(2010)中创建一种“模板”来接收一个或多个电子表格中的数据,然后根据XML模式将该数据转换为XML?或Excel中的任何类似功能?

I know there are several XML features in Excel but haven't found how to do what I want to do above.

我知道Excel中有几个XML功能,但还没有找到如何做我上面要做的事情。

Answers and comments appreciated.

答案和评论赞赏。

1 个解决方案

#1


1  

Did something similar quite some time ago. Might not be exactly what you want but should hopefully get you started in the right direction.

很久以前就做过类似的事了。可能不是你想要的,但希望能让你开始朝着正确的方向前进。

  • First enable the Developer tab in the ribbon. A simple google search should tell you how to do that.
  • 首先启用功能区中的“开发人员”选项卡一个简单的谷歌搜索应该告诉你如何做到这一点。
  • In the Developer tab, click on 'Import' button (in the 'XML' subtab). This should let you import an existing XML (data) file. This imports data as a table with appropriate column names. This would be your 'template'.
  • 在Developer选项卡中,单击'Import'按钮(在'XML'子选项卡中)。这应该允许您导入现有的XML(数据)文件。这会将数据导入为具有适当列名的表。这将是您的“模板”。
  • Now you can add/modify rows to this table and once done, right click (within the table) and use XML->Export in the context menu.
  • 现在,您可以向此表添加/修改行,完成后,右键单击(在表中)并在上下文菜单中使用XML-> Export。

Been a long time but remember facing issues with more complex XML files (multiple one-to-may relations or something) so this approach might be good only for relatively simple XML schemas (unless you combine this with an XSL transform).

很长一段时间,但记得面对更复杂的XML文件(多个一对一关系或其他)的问题,所以这种方法可能只适用于相对简单的XML模式(除非你将它与XSL转换结合起来)。

#1


1  

Did something similar quite some time ago. Might not be exactly what you want but should hopefully get you started in the right direction.

很久以前就做过类似的事了。可能不是你想要的,但希望能让你开始朝着正确的方向前进。

  • First enable the Developer tab in the ribbon. A simple google search should tell you how to do that.
  • 首先启用功能区中的“开发人员”选项卡一个简单的谷歌搜索应该告诉你如何做到这一点。
  • In the Developer tab, click on 'Import' button (in the 'XML' subtab). This should let you import an existing XML (data) file. This imports data as a table with appropriate column names. This would be your 'template'.
  • 在Developer选项卡中,单击'Import'按钮(在'XML'子选项卡中)。这应该允许您导入现有的XML(数据)文件。这会将数据导入为具有适当列名的表。这将是您的“模板”。
  • Now you can add/modify rows to this table and once done, right click (within the table) and use XML->Export in the context menu.
  • 现在,您可以向此表添加/修改行,完成后,右键单击(在表中)并在上下文菜单中使用XML-> Export。

Been a long time but remember facing issues with more complex XML files (multiple one-to-may relations or something) so this approach might be good only for relatively simple XML schemas (unless you combine this with an XSL transform).

很长一段时间,但记得面对更复杂的XML文件(多个一对一关系或其他)的问题,所以这种方法可能只适用于相对简单的XML模式(除非你将它与XSL转换结合起来)。