OleDB & mixed Excel datatypes : missing data

后端 未结 6 1089
长发绾君心
长发绾君心 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:57

    @Brian Wells Thank you, your suggestion did the trick, but not totally... Worked for the mixed field int-string, but the datetime columns went with strange characters after that, so i applied a "hack" over the "hack".

    1.- Do a System.Io.File.Copy and create a copy of the excel file.

    2.- Modify the Datetime column headers programatically at runtime to something in datetime format, i.e. "01/01/0001".

    3.- Save the excel, and then apply your trick doing the query with HDR=NO to the modified file.

    Tricky, yes, but worked, and reasonabily fast, if anyone has any alternative to this, i will be glad to hear.

    Greetings.

    P.D. Excuse my english, it isn't my native language.

提交回复
热议问题