while reading number greater than 12 digits from e

2020-04-18 07:09发布

问题:

i'm trying to read a number with length greater than 12 digits from excel file using c# using below query

 "select Format([F1], 'Number') as Code";

But i get only 12 digits correctly and the rest of the numbers are converted into zeroes.Why is it so??

Example : 787767786546347 when read from excel file what i get is 787767786546000

回答1:

According to MSDN:

Excel follows the IEEE 754 specification on how to store and calculate floating-point numbers. Excel therefore stores only 15 significant digits in a number, and changes digits after the fifteenth place to zeroes.

To work around this behavior, format the cell as text. The cell can then display up to 1,024 characters.

http://support.microsoft.com/kb/269370



标签: c# asp.net excel