I’m trying to use Cells.ExportDataTable and it is throwing an Aspose.Cells.CellsException:
Hi,
Thanks for your posting and using Aspose.Cells.
Please download and try the latest version:
Aspose.Cells for .NET v8.7.2.1 it works fine.
We have tested your excel file with the following sample code using the latest version and it exported the data from worksheet fine without any exception.
C#
Worksheet worksheet = workbook.Worksheets[0];
Range rng = worksheet.Cells.MaxDisplayRange;
DataTable dt = worksheet.Cells.ExportDataTable(rng.FirstRow, rng.FirstColumn, rng.RowCount, rng.ColumnCount, true);
dt.TableName = “MyTable”;
Try it with the following range and it will throw the exception:
Hi Martin,
Worksheet worksheet = workbook.Worksheets[0];
DataTable dt = worksheet.Cells.ExportDataTable(3, 0, 28, 19, new ExportTableOptions() { CheckMixedValueType = false, ExportColumnName = true, ExportAsString = true});
dt.TableName = “MyTable”;
Thanks. This should work for now.
Hi,
This was the issue for me. One column had a number in the first three rows and then a string in the following two rows. The column had “Text” format in Excel.
I added explicit options to not CheckMixedValueType:
var exportTableOptions = new ExportTableOptions { CheckMixedValueType = false, ExportColumnName = true, ExportAsString = true }; dataFromExcelSheet = worksheet.Cells.ExportDataTable(firstRow, firstColumn, totalRows, totalColumns, exportTableOptions);
Please set CheckMixedValueType to true if a column has both numeric and string values to escape from error.
Let us know if you still find the issue.