简体   繁体   English

如何将XML序列映射到Excel列?

[英]How do I map XML sequences to Excel columns?

I'm new to XML. 我是XML的新手。 What I have is a load of XML from Adobe Illustrator which I'm trying to map excel data onto. 我所拥有的是来自Adobe Illustrator的XML负载,我正在尝试将Excel数据映射到其中。 I have sequences in the original data which look like this 我在原始数据中有这样的序列

<Market_Pie>
<datanumDataColumns="5">
<values>
<row>
<valuekey="name"></value>
<value>503.931</value>
<value>268.301</value>
<value>285.561</value>
<value>152.037</value>
</row>
</values>
</data>
</Market_Pie>

Excel has created an XML map from this which sees this as a single sequence. Excel已从中创建一个XML映射,该映射将其视为单个序列。 When I try to associate this with various cells, it seems to want to see this as a single column. 当我尝试将其与各种单元格关联时,似乎希望将其视为单个列。 My data, however, is structured so that this data needs to be in a series of separate columns, one column for each value. 但是,我的数据经过结构化,因此该数据需要位于一系列单独的列中,每个值一个列。

I'm using Excel 2007, and just can't see how this is supposed to work. 我正在使用Excel 2007,但看不到它应该如何工作。 The help files seem remarkably unhelpful as well. 帮助文件似乎也无济于事。

In order to have each value get its own column, each value needs a unique key, something that would correspond to the the header for each column. 为了使每个值都有自己的列,每个值都需要一个唯一的键,该键对应于每个列的标题。 There are a couple of ways to cheat this: 有几种方法可以作弊:

  1. Import the data in one sheet, and have a formula or function in another sheet that works down the column and puts all values in columns. 将数据导入一张表中,并在另一张表中具有公式或函数,该公式或函数将列向下移动并将所有值放入列中。

  2. Give each value a unique element name or id. 为每个值赋予唯一的元素名称或ID。 Either: 要么:

     <Market_Pie> <data numDataColumns="5"> <values> <row> <valuekey="name"></value> <value1>503.931</value> <value2>268.301</value> <value3>285.561</value> <value4>152.037</value> </row> </values> </data> </Market_Pie> 

or 要么

   <Market_Pie>
   <data numDataColumns="5">
   <values>
   <row>
   <valuekey="name"></value>
   <value id="col1">503.931</value>
   <value id="col2">268.301</value>
   <value id="col3">285.561</value>
   <value id="col4">152.037</value>
   </row>
   </values>
   </data>
   </Market_Pie>

The problem with either solution reveals the actual problem with what you have in mind, which is: what if you had 200 values? 两种解决方案的问题都揭示了您所想到的实际问题,即:如果您有200个值怎么办? Do you actually want 200 columns? 您实际上想要200列吗? Typically sets of values go into columns, and each set gets its own column. 通常,值的集合进入列,并且每个集合都有自己的列。 If the values all belong to the same set, you probably want to have them in one column. 如果所有值都属于同一集合,则可能要将它们放在一列中。 But if columns fit your model, as your question suggests, I would go with using a function. 但是,如果列适合您的模型(如您的问题所暗示),我将使用函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM