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.

How to import a xlsx file into Essential Grid?

Thread ID:

Created:

Updated:

Platform:

Replies:

97662 Dec 22,2010 05:05 AM Jan 3,2011 06:45 AM Windows Forms 4
loading
Tags: GridControl
Sergey Koroliov
Asked On December 22, 2010 05:05 AM

Hi
I have Syncfusion 8.2.0.18
Is it possible to import a xlsx file into Essential Grid?
I've run your example "GC XLS Export Demo" from Essential Studio Samples\Grid samples tree. It imports xls files fine but if I select a xlsx file this string:

gecc.ExcelToGrid( openFileDialog.FileName, this.gridControl1.Model);

returns null reference exception:

{"Value cannot be null.\r\nParameter name: root"}



Jisha Joy [Syncfusion]
Replied On December 23, 2010 04:20 AM

Hi Sergey,

I have tested the issue in the "GC XLS Export Demo" sample. The importing of xlsx file to gridcontrol is working fine as expected. Please provide us the complete stack trace of the exception you are getting. So that we could analyze it further.

Regards,
Jisha


Sergey Koroliov
Replied On December 23, 2010 09:26 AM

Hi Jisha

I’ve managed to reproduce the exception in PC with Windows 7 64bit and in PC with Windows XP 32bit.
I am using Syncfusion 8.2.0.18.

You can see my steps to reproduce the exception in attached archive - Import_xlsx.png file
I also included the file that I tried to import - data_M1.xlsx

Regards, Sergey




Import_xlsx_953ad572.zip

Jisha Joy [Syncfusion]
Replied On December 29, 2010 04:10 AM

Hi Sergey,

You could solve the issue by opening the grid manually providing the ExcelOpenType to Automatic while opening the workbook, then the grid can be imported from the sheet of the workbook.

Please refer the code below:

ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook myWorkbook = null;
myWorkbook = excelEngine.Excel.Workbooks.Open("data_M1.xlsx", ExcelOpenType.Automatic);
IWorksheet mySheet = myWorkbook.Worksheets[0];
GridExcelConverterControl gecc = new GridExcelConverterControl();
gecc.ExcelToGrid(mySheet, this.gridControl1.Model);

Regards,
Jisha


Sergey Koroliov
Replied On January 3, 2011 06:45 AM

Hi Jisha

Thank you! It works fine.

Regards, Sergey


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.

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.

;