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

Free Support Forum - aspose.com

Error with ExportDataTable

I’ve got an error with the xlsx file and the code attache to this topic.
Aspose.zip (8.5 KB)


It seems like you are using Aspose.Cells. We are moving your inquiry in respective forum category where you will be assisted accordingly.


I checked your code which is not right. Please note, Worksheet.Cells.Columns.Count gives (zero-based) columns count (that are initialized), you may also use Worksheet.Cells.MaxDataColumn instead. So, you got to traverse your loop starting from “0” indexed position instead of “1”. See the updated code segment (that you may try) which works fine as I tested:
Sample code:

DataTable dt = new DataTable();
             for (int i = 0; i <= workbook.Worksheets[0].Cells.Columns.Count; i++)
                dt.Columns.Add().DataType = Type.GetType("System.String");

                options.DataTable = dt;
            workbook.Worksheets[0].Cells.ExportDataTable(0, 0, 44, 2, options);

Hope, this help a bit.