ASP. NET MVC or other programs cannot open the excel--solution, C # handles Excel files

Source: Internet
Author: User

Problem Description: Today, Excel encountered a problem, the local use of microsoft.jet.oledb.4.0 processing, the normal completion of the requirements,

An exception occurred after uploading to the server, by troubleshooting the discovery of a problem in the Excel file read, and then presumably because

Did not install the corresponding driver, and then on the Microsoft Official website to find the microsoft.ace.oledb.12.0; this driver,

This issue is resolved successfully after installation on the server, and it is important to note that the connection string needs to be changed to microsoft.ace.oledb.12.0;

Example

 Public StaticDataSet Exceltods (stringPath) {            //string strconn = "provider=microsoft.jet.oledb.4.0;" + "Data source=" + Path + ";" + "Extended properties=excel 8.0;"            ; //Open this comment after publishing            stringstrconn ="provider=microsoft.ace.oledb.12.0;"+"Data source="+ Path +";"+"Extended Properties=excel 8.0;"; OleDbConnection Conn=NewOleDbConnection (strconn); Conn.            Open (); stringStrexcel =""; OleDbDataAdapter mycommand=NULL; DataSet DS=NULL; Strexcel="select * FROM [sheet1$]"; MyCommand=NewOleDbDataAdapter (Strexcel, strconn); DS=NewDataSet (); Mycommand.fill (DS,"table1"); returnds; }

ASP. NET MVC or other programs cannot open the excel--solution, C # handles Excel files

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.