现在的位置: 首页 > 综合 > 正文

用OleDB读Excel文件

2011年03月29日 ⁄ 综合 ⁄ 共 656字 ⁄ 字号 评论关闭

        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..

 

抱歉!评论已关闭.