Workaround for NULL when reading Excel file

Source: Internet
Author: User
Tags first row

Reading an Excel file often occurs when you read certain fields with null values, because Excel takes the data type of the first row as a reference when you read the file, and there are problems if the back is inconsistent.

Following a friend's solution, his Excel file's connection string is written as follows. It is said that the data can be coerced into a string, specifically I did not test again. For reference only.

string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sPath + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1'";

Where the red part is noteworthy, HDR and IMEX must be used in conjunction, HDR is to use the first row as the data or column name, as the data with the Hdr=no, as the column name with the Hdr=yes, through imex=1 to the mixture as text read, avoid null value. Excel connection in SSIS is not the same as other connection, users do not need to specify the data type, Excel driver can do a sample first, and then based on the results to guess the data type.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.