Category / Section
How to export data from excel sheet to a datatable?
1 min read
The IWorksheet.ExportDataTable method is used to export data from excel sheet to DataTable. Please refer the below code snippet which illustrates this:
C#
//The first worksheet object in the worksheets collection is accessed.
IWorksheet sheet = workbook.Worksheets[0];
//Get as DataTable
DataTable datatable = sheet.ExportDataTable(sheet.UsedRange, ExcelExportDataTableOptions.ColumnNames);
//Upload to dataset
DataSet ds = new DataSet();
ds.Tables.Add(datatable);
VB
'The first worksheet object in the worksheets collection is accessed.
Dim sheet As IWorksheet = workbook.Worksheets(0)
'Get as DataTable
Dim datatable As DataTable = sheet.ExportDataTable(sheet.UsedRange, ExcelExportDataTableOptions.ColumnNames)
'Upload to dataset
Dim ds As DataSet = New DataSet()
ds.Tables.Add(datatable)
Did not find the solution
Contact Support
Iam unable to find methods other than importdata that can be used to add data to worksheet. Import data table is not available. I have added reference to syncdusion.xlsio in my xamarin Android project. Am i missing any other reference?