Syncfusion.XlsIO.Base
Example 


Syncfusion.XlsIO Namespace > IWorksheet Interface > ExportDataTable Method : ExportDataTable(Int32,Int32,Int32,Int32,ExcelExportDataTableOptions) Method
Row of the first cell from where DataTable should be exported.
Column of the first cell from where DataTable should be exported.
Maximum number of rows to export / upto number of rows.
Maximum number of columns to export / upto number of columns.
Export options using ExcelExportDataTableOptions enumeration.

ExportDataTable(Int32,Int32,Int32,Int32,ExcelExportDataTableOptions) Method

Exports worksheet data in the specified row and column into a System.Data.DataTable.
Syntax
'Declaration
 
Overloads Function ExportDataTable( _
   ByVal firstRow As Integer, _
   ByVal firstColumn As Integer, _
   ByVal maxRows As Integer, _
   ByVal maxColumns As Integer, _
   ByVal options As ExcelExportDataTableOptions _
) As DataTable
'Usage
 
Dim instance As IWorksheet
Dim firstRow As Integer
Dim firstColumn As Integer
Dim maxRows As Integer
Dim maxColumns As Integer
Dim options As ExcelExportDataTableOptions
Dim value As DataTable
 
value = instance.ExportDataTable(firstRow, firstColumn, maxRows, maxColumns, options)

Parameters

firstRow
Row of the first cell from where DataTable should be exported.
firstColumn
Column of the first cell from where DataTable should be exported.
maxRows
Maximum number of rows to export / upto number of rows.
maxColumns
Maximum number of columns to export / upto number of columns.
options
Export options using ExcelExportDataTableOptions enumeration.

Return Value

DataTable with worksheet data.
Remarks
This method is supported in ASP.NET Core, Xamarin, and UWP platforms from .NET Standard 2.0 onward. To know more about ExportDataTable refer this link.
Example
The following code illustrates how to exports worksheet data into a System.Data.DataTable with the specified row and column.
using Syncfusion.XlsIO;
using System.Data;
using System.Windows.Forms;
             
class public partial class Form1 : Form
{
   public Form1()
   {
     InitializeComponent();
     exportDataInGrid();
   }
   
   public void exportDataInGrid()
   {
     ExcelEngine excelEngine = new ExcelEngine();
     IApplication application = excelEngine.Excel;
     IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
     IWorksheet worksheet = workbook.Worksheets[0];
            
     //Import Data From Excel to DataTable
     DataTable dataTable = worksheet.ExportDataTable(1,1,40,4, ExcelExportDataTableOptions.ComputedFormulaValues);
     
     // Using dataGrid/gridControls you can view the exported DataTable's data
     this.dataGrid1.DataSource = dataTable;
            
     workbook.Close();
     excelEngine.Dispose();
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 16.4460.0.40

See Also