We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Import Excel to GridDataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

91698 Nov 28,2009 10:59 AM UTC Dec 2,2009 10:18 AM UTC ASP.NET Web Forms (Classic) 1
loading
Tags: GridGroupingControl
Hyung-Jin Lee
Asked On November 28, 2009 10:59 AM UTC

Hello.
How can I import the excel file to GridDataBoundGrid?

I found below ...


Syncfusion.GridExcelConverter.GridExcelConverterControl gecc = new Syncfusion.GridExcelConverter.GridExcelConverterControl();
gecc.ExcelToGrid(@"D:\excelTest.xls", this.gridDataBoundGrid1.Model);

But it import only one line at once.
If there are 100 or 1000 lines, I should run 100 or 1000 times.
Is there any way to import all data at once?
Please give me an advice.
Thank you.

Ranjeet Kumar [Syncfusion]
Replied On December 2, 2009 10:18 AM UTC

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.zip

Please, do let me know if you have any query.


Regards
Ranjeet

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;