我现在需要将repeat控件的数据导入到本地新建的Exel表中,请问各位大侠怎么实现,C#实现

解决方案 »

  1.   

      System.IO.StringWriter sw = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
            this.rpt_Object.RenderControl(hw);        Response.Clear();
            Response.ContentType = "application/vnd.ms-excel";
            Response.Charset = "";
            Page.EnableViewState = false;        Response.AppendHeader("Content-Disposition", "attachment;filename=Teacher.xls");
            Response.Write("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=utf-8\"><title>   Copyright by SDU</title></head><body><center>");
            Response.Write(sw.ToString()+"<\br>");
            Response.Write("</center></body></html>");
            Response.End(); 
      

  2.   

    参见
    http://dotnet.aspx.cc/file/Export-Gridview-To-Excel-With-Multi-Sheet.aspx