Exporting data from XLSX/XLS spreadsheet to datatable in any asp.net programming without Microsoft Office software.

XsExcel SDK not only facilitates its users to import data to worksheets from external data sources but also allow them to export their worksheet data to a DataTable.

This guide page provides C# users with how to export data from XLSX and XLS spreadsheet to Data Table with XsExcel control in C#.NET.

string filename = "DataTableSample.xlsx";
// Set the worksheet you want to export data from
int sheetId = 0;

// Create a workbook with local excel file
Workbook workbook = new Workbook(filename);

// Export data from worksheet to data table
DataTable dt = workbook.ConvertSheetToDataTable(sheetId);
return dt;

Notice - If you used the trial version of XsExcel SDK, can only edit, insert or get the first 300 row data!

More Excel tutorial