Hi Chin,
Thanks for using Syncfusion Products.
ExportDataTable() method of Syncfusion.XlsIO.IWorksheet object may be used to import all the data from the excel sheet
into Syncfusion's gridDataBoundGrid control as shown below with the help of attached sample codes. To execute the codes we are handling button4_Click event.
//Event button4_Click
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Files(*.xls)|*.xls";
openFileDialog.DefaultExt = ".xls";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook myWorkbook = excelEngine.Excel.Workbooks.Open(openFileDialog.FileName);
IWorksheet mySheet = myWorkbook.Worksheets[0];
// Import the contents of the Spreadsheet to a DataTable
DataTable dt = mySheet.ExportDataTable(1, 1, mySheet.UsedRange.End.Row, mySheet.UsedRange.End.Column, ExcelExportDataTableOptions.ColumnNames);
//Setting the datasource of the GridDataBoundGrid.
this.gridDataBoundGrid1.DataSource = dt;
excelEngine.ThrowNotSavedOnDestroy = false;
excelEngine.Dispose();
}
Please find the sample from the following link in which this code has been implemented.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=ImportExcelToGDBG1284456829.zipPlease, do let me know if you have any query.
Regards
Ranjeet