请教各位大侠一个asp.net中关于导出EXCEL的问题
各位大侠,小弟是asp.net新手,最近在用C#做项目时遇到导出EXCEL的问题;由于需要导出EXCEL样式很怪异,我做了模板并将其放在了发布目录\temp\下,如:1.xls;我现在需要在服务器端复制此文件为2.xls放于发布目录\out\下,并把2.xls中C3格子填入数据300,最后要在客户端ie下载打开2.xls
请各位大侠帮忙看看应该如何处理这个问题,如果能提供简单的代码的话,小弟不胜感激
--------------------编程问答-------------------- http://topic.csdn.net/u/20080311/11/6afbe634-1d88-4a99-b7f5-96599843405c.html --------------------编程问答-------------------- 开发环境是net2005+office2003 --------------------编程问答-------------------- UP --------------------编程问答-------------------- 哪位大侠能够提供简单点,有针对性的例子码,着急ing --------------------编程问答-------------------- 没人能够帮帮忙码 --------------------编程问答-------------------- public void ToExportSys(DataTable table,string Expandname)
{
System.Web.UI.WebControls.DataGrid dgr=new DataGrid();
dgr.ItemDataBound +=new DataGridItemEventHandler(dgr_ItemDataBound);
dgr.DataSource=table;
dgr.DataBind();
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=" + "" + DateTime.Now.ToShortDateString() +""+Expandname+"");
HttpContext.Current.Response.Charset = "gb-2312";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.UTF7;
HttpContext.Current.Response.ContentType = "application/ms-excel/ms-word";
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
dgr.RenderControl(hw);
dgr.Dispose();
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
导出EXCEL 代码
补充:.NET技术 , ASP.NET