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

Free Support Forum - aspose.com

Problem exporting excel worksheet in to datatable

hi i am trying to extract data table from excel worksheet. i am getting the following error on Worksheet.Cells.ExportDatable method.

ColumnName is required when it is part of a DataTable.

if i remove the row and re add it then it works fine. i am not sure whats wrong with it.
i am trying to evaluate the Aspose.cells. Attached is the file to test.

can you let me know if this can be solvable.


Thanks for your posting and considering Aspose.Cells for .NET.

Please use the ExportDataTableAsString method instead of ExportDataTable.

Please see the following sample code.



//Instantiating a Workbook object

Workbook workbook = new Workbook();

//Creating a file stream containing the Excel file to be opened

FileStream fstream = new FileStream("C:\\book1.xls", FileMode.Open);

//Opening the Excel file through the file stream


//Accessing the first worksheet in the Excel file

Worksheet worksheet = workbook.Worksheets[0];

//Exporting the contents of 7 rows and 2 columns starting from 1st cell to DataTable

DataTable dataTable = worksheet.Cells.ExportDataTableAsString(0, 0, 7, 2, true);

//Binding the DataTable with DataGrid

dataGrid1.DataSource = dataTable;

//Closing the file stream to free all resources