除了以下几种方法除外
1.使用Com 操作Excel (因为要设置权限)
2.使用Oledb操作因为以上方法我都试过不太合试自己的当前情况。

解决方案 »

  1.   

    实验下这段代码HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=Excel.xls");
    Response.ContentType = "application/vnd.ms-excel";
    HttpContext.Current.Response.Charset ="";
    HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
    DataGrid1.Page.EnableViewState =false;
    System.IO.StringWriter tw = new System.IO.StringWriter() ;
    System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
    DataGrid1.Visible=true;
    DataGrid1.RenderControl(hw);
    HttpContext.Current.Response.Write(tw.ToString());
    HttpContext.Current.Response.End();
      

  2.   

    http://sz.luohuedu.net/xml/ShowDetail.asp?id=8A4CBF47-B888-4832-3389-ED3A3A3C8AAB