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

Free Support Forum - aspose.com

Not able to read excel using ExportToDataTable() function

Please find the attached excel [colMD.zip (429.9 KB) ] and try to read the data using aspose cell’s below mentioned method.
DataTable table = excelWorkBook.Worksheets[0].Cells.ExportDataTable(0, 0, excelWorkBook.Worksheets[0].Cells.MaxDataRow + 1, excelWorkBook.Worksheets[0].Cells.MaxDataColumn + 1);

It gives an exception saying “The value of the cell A2 should not be a string value”

Please provide us a solution as soon as you can.

Regards,
Prathap

@PrathapSV,

I have evaluated your scenario and I believe the format of the date values is being changed in the exported DataTable due to localization. Please try the following piece of code on your side as I am able to get correct results with it.

Workbook excelWorkBook = new Workbook("colMD.xlsx");
excelWorkBook.Settings.Region = CountryCode.Default;
DataTable table = excelWorkBook.Worksheets[0].Cells.ExportDataTable(0, 0, excelWorkBook.Worksheets[0].Cells.MaxDataRow + 1, excelWorkBook.Worksheets[0].Cells.MaxDataColumn + 1 , new ExportTableOptions() { CheckMixedValueType = true });

Let us know your feedback.