Import bulk Excel data into an Oracle database import Excel error: External table is not the expected format solution

Source: Internet
Author: User

After you export the Excel file in the ASP. NET Web site, import the file into the database. Error opening connection when reading Excel file.

Error: External table is not in expected format

FIX: Checked, the exported Excel is standard file is not HTML, yes, Excel file is normal.

Debug code, create Connection object OleDbConnection is also normal, but in Conn. Open () An error occurred while opening the link.

Look closely at the link string, check out the error, Excel version problem, EXCE connection string version is office2003, change to Excel2007 version is normal import.

The summary rules are as follows:

usingSystem.Data.OleDb;usingSystem.Data; Public voidreadexcelfiless () {//string strconn = "provider=microsoft.jet.oledb.4.0;" + "Data source=" + Server.MapPath ("Excelfiles/myexcelfile.xls ") + "; Extended properties= ' Excel 8.0; Hdr=yes; Imex=1 ' "; //This connection can only manipulate Excel2007 (. xls) files            stringstrconn ="provider=microsoft.ace.oledb.12.0;"+"Data source="+ Server.MapPath ("excelfiles/mydata2007.xlsx") +"; Extended properties= ' Excel 12.0; Hdr=yes; Imex=1 '";//This connection can manipulate the. xls and. xlsx files (connection strings that support Excel2003 and Excel2007)//remark: "Hdr=yes;" Is that the first line of the Excel file is the column name instead of the data, "HDR=NO;" It's just the opposite of the front. //"Imex=1" if the data type in the column is inconsistent, the use of "imex=1" will avoid data type collisions. OleDbConnection Conn=NewOleDbConnection (strconn); OleDbDataAdapter ADP=NewOleDbDataAdapter ("Select * FROM [sheet1$]", conn); DataSet DS=NewDataSet (); Adp. Fill (DS,"Book1");  This. Gridview1.datasource = ds. tables["Book1"].            DefaultView;  This.         Gridview1.databind (); }

From: https://www.cnblogs.com/kingkongv/archive/2012/08/26/2657436.html

Import bulk Excel data into an Oracle database import Excel error: External table is not the expected format solution

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.