错误:<target> .ColumnName和<source> .ColumnName具有冲突的属性:DataType属性不匹配

我正在尝试使用DataTable.Merge()选项合并多个Excel文件

For Each fileName As String In Directory.GetFiles("C:\TEMP\.", "*.xls") Dim connectionString As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=""Excel 8.0;HDR=NO;IMEX=1;""", fileName) Dim adapter As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString) Dim ds As New DataSet adapter.Fill(ds, "anyNameHere") Dim TempTable As DataTable TempTable = ds.Tables.Item("anyNameHere") table1.Merge(TempTable) MsgBox(fileName) Next DataGridView1.DataSource = table1 MsgBox(table1.Rows.Count) 

但在合并时出现以下错误

 <target>.ColumnName and <source>.ColumnName have conflicting properties: DataType property mismatch. 

这是由于在excel中的一列被读为文本而另一个为双精度,而两者都有数字值。

为了避免这种情况,我在连接string中也提到了IMEX = 1,仍然出现这个错误。

在Merge中使用MissingSchemaAction.Ignore作为MissingSchemaAction参数

 table1.Merge(TempTable, True, MissingSchemaAction.Ignore) 

如果列是数字,请将xls文件作为文本处理。
当你合并数据时你不希望列在结构上是相同的吗?