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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

import range of cells from excel worksheet to gridcontrol

Thread ID:





84360 Jun 30,2009 12:12 PM UTC Jul 6,2009 03:13 PM UTC WinForms 1
Tags: GridControl
Asked On June 30, 2009 12:12 PM UTC

import range of cells from excel worksheet to gridcontrol

Lingaraj S [Syncfusion]
Replied On July 6, 2009 03:13 PM UTC


Thank you for your interest in SYncfusion product.

The ExcelToGrid method from the GridExcelConverterControl will get the range of datas from the excel sheet and assign the value of each cell from the excel to the grid along with it look and feel, like its row width, and cell style, this has been handled internally in the GridExcelConverterControl class.
If you want to import the data from the excel range, you can handle it by adding it to a DataTable and populating the datas from the DataTable will retains the look and feel of the control.

Please refer the code below:
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("../../Sample1.xls");
IWorksheet sheet = workbook.Worksheets[0];
// Specify the Range In this the Used range used.
DataTable dt = sheet.ExportDataTable(sheet.UsedRange, ExcelExportDataTableOptions.ColumnNames | ExcelExportDataTableOptions.DetectColumnTypes);
this.gridControl1.RowCount = dt.Rows.Count;
this.gridControl1.ColCount = dt.Columns.Count;
this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, dt.Rows.Count, dt.Columns.Count), dt);

Please let me know if you have any queries.

Lingaraj S.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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