日期:2014-05-17 浏览次数:20443 次
string strPath = UploadFile(FileUpload1, Server.MapPath("/uploads/excel/")); string sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Server.MapPath("/uploads/excel/") + strPath + ";" + "Extended Properties=\"Excel 8.0;HDR=Yes;\""; //Utility.Utility.Go_Error(Server.MapPath(FileUpload1.PostedFile.FileName.ToString())); //string sConnectionString = @"Provider=MICROSOFT.JET.OLEDB.4.0;Extended Properties='Excel 8.0;IMEX=1';DATA SOURCE=" + FileUpload1.PostedFile.FileName.ToString(); //建立EXCEL的连接 OleDbConnection objConn = new OleDbConnection(sConnectionString); // Utility.Utility.Go_Error(strPath); objConn.Open(); OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [" + FileUpload1.FileName.Substring(0, FileUpload1.FileName.IndexOf('.')) + "$]", objConn); OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(); objAdapter1.SelectCommand = objCmdSelect; DataSet objDataset1 = new DataSet(); objAdapter1.Fill(objDataset1, "XLData"); DataTable dt = objDataset1.Tables[0];
<configuration> <system.web> <httpRuntime maxRequestLength="1048576" executionTimeout="3600" /> <processModel memoryLimit="80"/> </system.web> </configuration>