OpenXML:XML和Excel工作表具有不同的值

时间:2014-06-30 19:52:43

标签: excel openxml

当我使用OpenXML阅读Excel工作表时,我在Excel中的单元格值有不同的值。这发生在OpenXML Productivity Tool,我的代码中,当我将扩展名更改为.zip并在浏览器中查看XML时。例如,这是我的Excel表格的一部分(抱歉,我没有足够的“声誉”来发布工作表的图像):

SAMPLE ID   ANALYTE ID  RESULT QUANTIFIER   RESULT
782-3M-000085   75-35-4 <   0.11
782-3M-000085   56-23-5 <   0.0006
782-3M-000085   156-59-2    <   0.497
782-3M-000085   75-69-4 <   0.0009
782-3M-000085   67-66-3 <   0.008
782-3M-000085   76-13-1 <   0.006
782-3M-000085   127-18-4        1.79

,XML看起来像这样(部分内容):

 <row r="1" spans="1:18" ht="38.25" x14ac:dyDescent="0.2">
 <c r="A1" s="30" t="s">
  <v>103</v> 
  </c>
 <c r="B1" s="30" t="s">
  <v>6</v> 
  </c>
 <c r="C1" s="30" t="s">
  <v>24</v> 
  </c>
 <c r="D1" s="30" t="s">
  <v>104</v> 
  </c>
 <c r="E1" s="30" t="s">
  <v>105</v> 
  </c>
   </row>
 <row r="2" spans="1:18" x14ac:dyDescent="0.2">
 <c r="A2" t="s">
  <v>48</v> 
  </c>
 <c r="B2" t="s">
  <v>115</v> 
  </c>
 <c r="C2" s="36" t="s">
  <v>116</v> 
  </c>
 <c r="D2">
  <v>0.11</v> 
  </c>
 <c r="E2" t="s">
  <v>117</v> 
  </c>
   </row>
 <row r="3" spans="1:18" x14ac:dyDescent="0.2">
 <c r="A3" t="s">
  <v>48</v> 
  </c>
 <c r="B3" t="s">
  <v>123</v> 
  </c>
 <c r="C3" s="36" t="s">
  <v>116</v> 
  </c>
 <c r="D3">
  <v>5.9999999999999995E4</v> 
  </c>
   </row>
 <row r="4" spans="1:18" x14ac:dyDescent="0.2">
 <c r="A4" t="s">
  <v>48</v> 
  </c>
 <c r="B4" t="s">
  <v>124</v> 
  </c>
 <c r="C4" s="36" t="s">
  <v>116</v> 
  </c>
 <c r="D4">
  <v>0.497</v> 
  </c>
   </row>

有人知道我做错了什么吗?我正在尝试将工作表中的值导入到我的代码中。

1 个答案:

答案 0 :(得分:1)

@psantiago是对的 - 您正在处理&#34;共享字符串&#34;。

&#39;&#39; cell元素的属性告诉您单元格中的数据类型是什么。 (OpenXml标准中的第18.3.1.4节)。在这种情况下,&#39; -value会告诉您该值是SharedStrings文件的索引。 (标准的18.18.11节ST_CellType(Cell Type))。因此,在SharedStrings.xml文件的索引48处,您将找到所需的信息。

还要注意包含值&#34; 0.11&#34;的单元格的差异。

<c r="D2">
  <v>0.11</v> 
</c>

它没有&#34;单元格数据类型&#34;属性所以这个值只是&#34; 0.11&#34;直接在牢房里。

您可以在http://standards.iso.org/ittf/PubliclyAvailableStandards/index.html获取完整文档 - 在页面上搜索&#34; ISO / IEC 29500-1:2012&#34;