We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Decimal values are being read as Exponential values


I am using Aspose for processing an excel in my application. However some of the cells contain decimal values which excel is converting to exponential. I need to read the original decimal values while processing and not the exponential form. How can it be done using Aspose? I cannot manually modify the excel here as it comes from an external source.



Hi Hemangajit,

Thank you for considering Aspose.

You can use Cells[index].Value property to read the original value present in the cell. Please see the sample code which will help you getting your desired result.

Sample Code:

Workbook workbook = new Workbook();
Cells cell = workbook.Worksheets[0].Cells;
// get decimal value from a decimal type cell
Cells cell = workbook.Worksheets[0].Cells;
for (int i = 1; i < 8; i++)
if (CellValueType.IsNumeric == cell[i, 1].Type)
decimal originalValue = (decimal)cell[i, 1].Value;

// add the code to use the decimal value from the cell

Thank you & Best Regards,

Thanks a lot Nausherwan. It worked fine. One addition from my side. We need to do like

Decimal.Parse(cell[i, 1].Value.ToString(), System.Globalization.NumberStyles.Any). Because

cell[i, 1].Value.ToString() returns like "3E-02" for which I was getting exception while converting to Decimal.

It worked and thanks a lot for your quick response.