asp.net 页面导出word
来源:互联网 发布:淘宝商品广告违规 编辑:程序博客网 时间:2024/05/17 03:54
终于成功了
总的说是utf-8不行就GB2312
protected void Button_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AddHeader("Content-Disposition", "attachment; filename=MyInvoice.doc");//这样的话,可以设置文件名为中文,且文件名不会乱码。其实就是将汉字转换成UTF8
//Response.AddHeader("Content-Disposition", "attachment; filename=" + DateTime.Now + ".doc");//这样的话,可以设置文件名为中文,且文件名不会乱码。其实就是将汉字转换成UTF8
//如果设置为 GetEncoding("GB2312");导出的文件将会出现乱码!
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.HeaderEncoding = System.Text.Encoding.GetEncoding("GB2312"); //表头添加编码格式
Response.ContentType = "application/ms-word";//设置输出文件类型为excel文件。
//关闭控件的视图状态
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
Panel1.RenderControl(oHtmlTextWriter);//Add the Panel into the output Stream.
//this.GridView1.RenderControl(oHtmlTextWriter);//将gridview输出,你也可以类似的写TextBox1.RenderControl...
Response.Output.Write(oStringWriter.ToString());//Output the stream.
Response.Flush();
Response.End();
}
//重载VerifyRenderingInServerForm方法,否则运行的时候会出现如下错误提示:“类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内”
public override void VerifyRenderingInServerForm(Control control)
{
//override VerifyRenderingInServerForm.
}
- asp.net 页面导出word
- asp.net 导出Word
- ASP .NET导出word
- ASP.NET导出页面内容至word文档
- ASP.NET导出页面内容至word文档
- asp.net 导出Excel/Word
- asp.net 导出到word
- Asp.net导出Word方法
- 【原】asp.net导出word,结果导出aspx页面文件的问题
- 将asp页面导出到WORD
- asp.net 页面导出EXCEL
- 将ASP.NET页面内的数据导出到Excel 或 Word中
- 将ASP.NET页面内的数据导出到Excel或Word中
- 将ASP.NET页面内的数据导出到Excel或Word中
- 将ASP.NET页面内地数据导出到Excel 或 Word里面
- asp.net页面指定控件导出为Word 或excel 文档
- asp.net后台打印和导出WORD关闭页面JS真对 windows.open()方法
- ASP.NET导出通用(Word,Excel)
- Universal Windows App Development with Cortana and the Speech SDK 5
- ServiceStack.Redis常用操作 - 事务、并发锁
- Material Theme
- Mac下安装MySQLdb(包含有eclipse中关于MySQLdb的设置)
- cache性能优化
- asp.net 页面导出word
- Public Repositories仓库中的jar包来源问题
- swift UI专项训练10 视图共性
- Android Volley完全解析(一),初识Volley的基本用法
- sqoop--1.99.3--安装
- Material Design UI Widgets
- adb shell 打印小结
- 清晨雨后
- Partition List