ExcelToGrid, empty cells?

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

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

ExcelToGrid
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 6.4.0.14


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.

Try
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")
Finally
gecc.Dispose()
End Try
End If


2 Replies

MP Markus Persson October 16, 2008 03:37 PM UTC

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

Find:

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.




SR Sridhar Syncfusion Team 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.
 
Thanks,
Sridhar.S

Loader.
Up arrow icon