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

Free Support Forum - aspose.com

How to Import excel data into data table from filepath using aspose.cells?

I want to import excel data(from filepath) into data table using aspose.cells(only sheet 1 to get into datatable). Sheet should be imported from filepath.

Can you pls say how to do for this.

Thanks in advance.


Thanks for your query.

Well, you may try Data exporting options provided by Aspose.Cells to export the data to a DataTable or Arrays (see the document for your reference:
https://docs.aspose.com/display/cellsnet/Export+Data+from+Worksheet). For example, you may try ExportDataTable() method to fill a DataTable. Aspose.Cells can help you to load your template file and do the manipulation in the template file and then exporting your desired data set (of the worksheet) to fill a data table or arrays.

See the sample code below for your reference:
Sample code:

DataTable dt = new DataTable();
Workbook wb = new Workbook(“e:\test2\Book1.xlsx”);
//Export all the data of the first worksheet to fill the datatable.
dt = wb.Worksheets[0].Cells.ExportDataTable(0, 0, wb.Worksheets[0].Cells.MaxDataRow + 1, wb.Worksheets[0].Cells.MaxDataColumn + 1);

Hope, this helps a bit.

Thank you.