简单的,可以使用控件的方法,如
//Excel
Response.AppendHeader("Content-Disposition", "attachment;filename=temp.xls");
Response.ContentType = "application/ms-excel";
System.IO.StringWriter writer = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(writer);
this.pnlPrinter.RenderControl(htmlWriter);
//输出
Response.Write(writer.ToString());
Response.End();
复杂的,你可以使用数据源自己生成excel文件,并插入数据,网上有excelhelper之类的现成的操作excel的类可以下载下来使用