我可以帮您翻译成中文。这段代码是用于导入指定格式的Excel表格。其中一个列大多数数据是数字,但也有非数字值。出于某种原因,导入代码忽略了非数字值。
连接字符串如下:
实际的导入代码大致如下:
请注意,我已启用 IMEX = 1 以通知Excel存在混合数据。这似乎没有帮助。有什么想法?
连接字符串如下:
Dim FileConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & Path & "\" & _
Filename & ";Extended Properties=" & _
"""Excel 12.0;HDR=YES;IMEX=1;"""
实际的导入代码大致如下:
Dim Factory As DbProviderFactory = _
DbProviderFactories.GetFactory("System.Data.OleDb")
Dim Adapter As DbDataAdapter = Factory.CreateDataAdapter(), _
DataObject As New DataSet
Using Connection As DbConnection = Factory.CreateConnection
Connection.ConnectionString = FileConnectionString
Using Command As DbCommand = Connection.CreateCommand
Command.CommandText = _
"SELECT [Column1], [Column2]" & _
"FROM [Sheet1$]"
Adapter.SelectCommand = Command
Adapter.Fill(DataObject)
...
请注意,我已启用 IMEX = 1 以通知Excel存在混合数据。这似乎没有帮助。有什么想法?