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

ExcelToGrid, empty cells?

Thread ID:





77152 Oct 16,2008 02:03 PM UTC Aug 30,2012 06:21 AM UTC WinForms 2
Tags: XlsIO
Markus Persson
Asked On October 16, 2008 02:03 PM UTC

A1: 1, B1: 2
A2: 3, B2: 4

A1: 5, B1: 6
A2: 7, B2: Nothing/Null/Empty

A1: 5, B1: 6
A2: 7, B2: 4

What I expected
A1: 5, B1: 6
A2: 7, B2: Nothing/Null/Empty

How do I fix so I get the result I expected with ExcelToGrid?
I'm using Syncfusion

My code:
Dim ofd As OpenFileDialog = New OpenFileDialog()
ofd.Filter = "Excel (*.xls)|*.xls"
ofd.DefaultExt = ".xls"

If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim gecc As Syncfusion.GridExcelConverter.GridExcelConverterControl = New Syncfusion.GridExcelConverter.GridExcelConverterControl()
gecc.ExportStyle = False ' This doesn't seem to work when doing ExcelToGrid.

Dim ee As Syncfusion.XlsIO.ExcelEngine = New Syncfusion.XlsIO.ExcelEngine()
Dim wb As Syncfusion.XlsIO.IWorkbook = ee.Excel.Workbooks.Open(ofd.FileName)
Dim ws As Syncfusion.XlsIO.IWorksheet = wb.Worksheets(0)
ws.DeleteRow(1) ' I'm using ConverterOptions.RowHeaders with GridToExcel, need to remove the first row with columnnames before I do ExcelToGrid.
gecc.ExcelToGrid(ws, Me.GridControl1.Model)
Catch ex As Exception
MessageBox.Show(ex.Message, "ImportFromExcel")
End Try
End If

Markus Persson
Replied On October 16, 2008 03:37 PM UTC

I found myself a solution. Here's what I did.


gecc.ExcelToGrid(ws, Me.GridControl1.Model)

Replace with:

Me.GridControl1.Model.RowCount = 0 ' Clear the whole grid
gecc.ExcelToGrid(ws, Me.GridControl1.Model)
Me.GridControl1.Model.RowCount = Me.GridControl1.Model.RowCount - 1 ' We get an empty row at the end, probably because of the "DeleteRow(1)"-call earlier. This will remove the empty row since it's at the bottom.

Sridhar [Syncfusion]
Replied On August 30, 2012 06:21 AM UTC

Hi Markus,
Thank you so much for the update.
Please let us know if you have any further clarifications.


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