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