![]() |
用客户端脚本,就可以导出Word和Excel
在服务器端,示范代码如下:
Response.Clear(); Response.Buffer=true; //使用中文 Response.Charset="gb2312"; Response.AppendHeader("Content-Disposition","attachment;filename="+file+".xls"); Response.ContentEncoding=System.Text.Encoding.GetEncoding("gb2312"); //设置格式为Excel Response.ContentType="application/ms-excel"; EnableViewState=false; System.IO.StringWriter sw=new System.IO.StringWriter(); HtmlTextWriter tw=new HtmlTextWriter(sw); dg.RenderControl(tw); Response.Write(sw.ToString()); Response.End(); 你就可以实现把指定区域导出成Excel了,呵呵!(没有客户端脚本,不需要安装任何东西) |
回复: 用客户端脚本,就可以导出Word和Excel
这样的前提就是客户端必须安装word 、excel,然后是利用了ActiveX来操作,完全客户端化的。
|
所有的时间均为北京时间。 现在的时间是 01:04 PM. |