Problem in reading numeric value from excel (.xlsx)

Topics: Developer Forum
Mar 7, 2012 at 12:11 PM
Edited Mar 7, 2012 at 12:47 PM

I am reading the numeric value from excel file through officeopenxml like below:

Convert.ToString(ExcelWorkSheet.Cell(1, 1))

The actual value in excel file and it's output after reading is as below:

Values in Excel         output after reading from
excel cell using OfficeOpenXml
2345.6789 2345.6788999999999
4567.89765 4567.8976499999999
5678.2345 5678.2344999999996
753.3241 753.32410000000004

Can some one please let me know what to do in order to read the same value as written in excel.

 

Thanks,

Kunal Khosla

Mar 20, 2012 at 5:21 AM

Hi dude..

Use the below code for the above...

Decimal.ToDouble(Convert.ToDecimal(worksheet.Cell( row, col).Value))

 

Thanks & Regards,

Akbar