Home » excel » asp.net – while reading number greater than 12 digits from excel using c#,number get converted to zero

asp.net – while reading number greater than 12 digits from excel using c#,number get converted to zero

Posted by: admin May 14, 2020 Leave a comment

Questions:

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

How to&Answers:

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