OleDB & mixed Excel datatypes : missing data

后端 未结 6 990
长发绾君心
长发绾君心 2020-11-22 03:04

I have an Excel worksheet I want to read into a datatable - all is well except for one particular column in my Excel sheet. The column, \'ProductID\', is a mix of values lik

6条回答
  •  广开言路
    2020-11-22 03:53

    There are two ways to handle mixed datatypes & excel.

    Method 1

    • Open up your excel spreadsheet and set the column format to the desired format manually. In this case, 'Text'.

    Method 2

    • There is a "hack" that consists of appending "IMEX=1" to your connection string like so:

      Provider=Microsoft.Jet.OLEDB.4.0;Data Source=myfile.xls;Extended Properties=Excel 8.0;IMEX=1

    • This will attempt to handle mixed Excel formats according to how it is set in your registry. This can be set locally by you, but for a server, this is probably not an option.

提交回复
热议问题