Skip to content

Commit d73c366

Browse files
authored
Merge pull request #1736 from syncfusion-content/988142-DataTable
988142 - How to get DataTable from excel given a global workbook range
2 parents 33aeeda + 523af58 commit d73c366

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Document-Processing/Excel/Excel-Library/NET/Import-Export/Export-from-Excel.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ using (ExcelEngine excelEngine = new ExcelEngine())
2525
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
2626
IWorksheet worksheet = workbook.Worksheets[0];
2727

28-
//Read data from the worksheet and Export to the DataTable
29-
DataTable customersTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.ColumnNames | ExcelExportDataTableOptions.ComputedFormulaValues);
28+
//Read all data from the used range of worksheet and Export to the DataTable
29+
DataTable customersTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.ColumnNames | ExcelExportDataTableOptions.ComputedFormulaValues);
30+
31+
IRange range = worksheet.Range["A1:B10"];
32+
33+
//Read specified range from the worksheet and Export to DataTable
34+
DataTable customersTable1 = worksheet.ExportDataTable(range, ExcelExportDataTableOptions.ColumnNames | ExcelExportDataTableOptions.ComputedFormulaValues);
3035
}
3136

3237
//XlsIO supports binding of exported data table to data grid in Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms alone.

0 commit comments

Comments
 (0)