' Import from Excel Public Function ImportFromExcel() As Boolean Dim lcConnection As String = "" lcConnection = "provider=Microsoft.Jet.OLEDB.4.0; " + _ "data source='" + cSource + "'; Extended Properties=Excel 8.0;" ' Assign the source directory oConnection = New OleDbConnection(lcConnection) ' Select the data from Sheet1 of the workbook oDataAdapter = New OleDbDataAdapter("Select * From [" + cWorkbook + "$]", oConnection) Try oDataAdapter.Fill(oDataSet) Catch loError As Exception cError = loError.Message ' Try to extrapolate Select Case cError Case "External table is not in the expected format." cError = aMessage(1, nLanguage) Case "'Schema$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long." cError = aMessage(2, nLanguage) End Select Return False End Try ' Record count nCount = oDataSet.Tables(0).Rows.Count Return True End FunctionThis is pretty straight forward. Now, I can do this to access a row and a column:
' Import all the rows For lnCounter = 0 To loImport.nCount - 1 loRow = loImport.oDataSet.Tables(0).Rows(lnCounter) Try If Not loRow("Numero") Is DBNull.Value Then lnNumero = Val(loRow("Numero")) End IfSo, at this point, I assume the column Numero to exist. But, in Excel, if the user named that column Numero + a space at the end, this is imported as is. Is there any way to know about it, trim it or avoid it?