Help Needed--Excel reads 5.1 value supplied as 5.0999999999999996 and 4.9 as 4.9000000000000004

Nov 2, 2011 at 6:48 AM

Hi All

I have used excel reader in my application and when i try to read the file the values supplied are getting changed.Initial investigation from me shows this is happening with only these 2 values...5.1 and 4.9

Does anybody have an idea why this is happening..? Below is the way i am getting the data..

   else if (Path.GetExtension(FilePath).ToUpper() == ".XLSX")
                    excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                    excelReader.IsFirstRowAsColumnNames = true;
                    ds = excelReader.AsDataSet();

Please provide a solution to this problem.

I sincerely appreciate any help in this regard.This is crucial to my application and is an emergency.....

Mar 1, 2012 at 3:11 AM

While reading xlsx file if the decimal position is more than 2 places it shows a big number?

Any help?

Mar 13, 2012 at 8:06 AM

late but a temporary fix would be to round your numbers to the nearest tenths decimal place.