string strCon;
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("excel.xls") + "; Extended Properties=Excel 8.0;";
OleDbConnection olecon = new OleDbConnection(strCon);
OleDbDataAdapter myda = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strCon);
DataSet myds = new DataSet();
myda.Fill(myds);
return myds;
注意:
.net 的进程impersonate用户须对
Tried changing the permissions on:
C:\Documents and Settings\<machine name >\ASPNET\Local Settings\Temp
to include
IUSER_MACHINENAME
IWAM_MACHINENAME
ASPNET already has full rights..
Fixed by adding impersonate=true to web.config and setting adding ASPNET on c:\windows\temp directory (win2k3) to FULL RIGHTS..