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

Free Support Forum - aspose.com

Decimal values

when trying to import excel to datatable with the follwing code :

DataSet data = new DataSet();
ex = null;

ExportTableOptions options = new ExportTableOptions();

options.CheckMixedValueType = true;

Workbook wbk = new Workbook(excelFileStream);
wbk.CalculateFormula();

foreach (Worksheet wks in wbk.Worksheets)
{

if (wks.Cells.MaxDataRow > -1 && wks.Cells.MaxDataColumn > -1)
data.Tables.Add(wks.Cells.ExportDataTable(0, 0, wks.Cells.MaxDataRow + 1, wks.Cells.MaxDataColumn + 1, options));

int index = 0;
foreach (DataColumn col in data.Tables[data.Tables.Count - 1].Columns)
{


col.ColumnName = “Column_” + index++;
}
}

return data;

please note that when some cells in the sheet have decimal values like : 0.00005
when tranforming it to datatable this value transform to exponentiel values like : 1E95 etc…
if there a way to fix that ? or is there a way that i can specify the number format or digits after dots
(we have Aspose.Cells version 8.2.2.0 with license version 3.0)

the issue has been fixed by using ExportDataTableAsString insted of ExportDataTable

Hi,


Well, this is MS Excel’s behavior that converts these types of values to exponential notations. You have done fine to use ExportDataTableAsString instead, this way the original values would be retained.

Let us know if we can be of any further help.

Thank you.