Ok here is the scenario.
My Excel File has 30k rows with mixed data. I am using this code to populate the DGV from Excel
The code works fine but DGV misses some data. On searching, I came across THIS post by jm. I did the registry fix and every thing was ok.Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strCon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & txtFileName.Text & "; Extended Properties=""Excel 12.0 XML;HDR=YES;IMEX=1;""" Dim cnn As New OleDbConnection(strCon) Dim oconn As New OleDbCommand("select * from [Sheet1$]", cnn) cnn.Open() Dim adp As New OleDbDataAdapter(oconn) Dim dt As New DataTable() adp.Fill(dt) dgvExcelData.SelectionMode = DataGridViewSelectionMode.FullRowSelect dgvExcelData.EditMode = DataGridViewEditMode.EditProgrammatically dgvExcelData.DataSource = dt End Sub
I know I can use the Open XML SDK but that is not the reason for this post. I am simply curious.
My Question
I want to know if there is a way where the user doesn't need to modify the registry and the above code works for xl2007+ Files (Not text/csv Files so not sure if schema.ini can be used for xlsx/xlsm)
Let me know if anyone wants a sample data?
OS: Win 7 64 Bit
VS 2010 Ultimate 64 Bit
MS Office(not that it matters since using ole): 32 bit




Reply With Quote