简体   繁体   English

读取单元格值保持精度

[英]read cell value preserve precision

I am Reading Excel using C# with 我正在使用C#阅读Excel
string cellvalue= worksheet.Cells[2, 2].Text; 字符串cellvalue = worksheet.Cells [2,2] .Text; and the exact value in that cell is 0.0833333333333333 but the above code could only read value 0.083333333 which is the visible value in the excel sheet as well. 并且该单元格中的确切值为0.0833333333333333,但上述代码只能读取值0.083333333,这也是excel工作表中的可见值。 this is cause of data loss/precision loss. 这是数据丢失/精度丢失的原因。 how should i read the value of excel cell to get the 16 digit precision. 我应该如何读取Excel单元格的值以获得16位精度。

Thanks Charles, Value2 worked for me. 谢谢查尔斯,Value2为我工作。 Initially i was not able to find value2 on Cell. 最初我无法在Cell上找到value2。 Then I used object rangeObject = sheet.Cells[row, column]; 然后,我使用对象rangeObject = sheet.Cells [row,column]; Range range = (Range)rangeObject; 范围range =(Range)rangeObject; string cellValue; 字符串cellValue; cellValue = rangeValue != null ? cellValue = rangeValue!=空吗? rangeValue.ToString() : 0.ToString() rangeValue.ToString():0.ToString()

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

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