excel中的XML导出不遵循单元格格式

时间:2022-09-17 20:25:10

I have an excel table where the cell format is set to numbers with 3 digits. when I export this table to an XML, the numbers I get in the XML file are with 14 digits while I need only 3. I precise that I check the box keep the format when I do the exporting. here is the XML I get:

我有一个excel表,其中单元格格式设置为3位数字。当我将这个表导出为XML时,我在XML文件中获得的数字是14位数,而我只需要3位。我确切地说,我在选择框时保留导出时的格式。这是我得到的XML:

  <years>
 <Y2013>33.62462779075865</Y2013> 
 <Y2014>34.29511617341695</Y2014> 
 <Y2015>22.99556015765178</Y2015> 
 <Y2016>21.72323650695616</Y2016> 
 <Y2017>23.47566955177833</Y2017> 
  </years>

in the original table I have : 33.625 , 34.295 etc

在原始表中我有:33.625,34.295等

1 个解决方案

#1


0  

One solution that worked for me is to build a quick vba function that returns String instead of a double. I used the following instructions:

一个对我有用的解决方案是构建一个快速的vba函数,它返回String而不是double。我使用了以下说明:

value=Format(value, "0.000") 'returns a string formatted like 0,001 or 35,000
value= replace(value, ",",".") ' permits to set the right separator

value can be at the beginning in any type but becomes a String at the end

value可以在任何类型的开头,但最后变为String

#1


0  

One solution that worked for me is to build a quick vba function that returns String instead of a double. I used the following instructions:

一个对我有用的解决方案是构建一个快速的vba函数,它返回String而不是double。我使用了以下说明:

value=Format(value, "0.000") 'returns a string formatted like 0,001 or 35,000
value= replace(value, ",",".") ' permits to set the right separator

value can be at the beginning in any type but becomes a String at the end

value可以在任何类型的开头,但最后变为String