首页 新闻 会员 周边

.net 将页面内容导出到word,图片无法显示问题!

0
悬赏园豆:20 [已关闭问题] 关闭于 2010-11-30 10:00

public void ExportControl(System.Web.UI.Control source, string DocumentType, string filename) { //设置Http的头信息,编码格式 if (DocumentType == "Excel") { //Excel HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename + ".xls", System.Text.Encoding.UTF8)); HttpContext.Current.Response.ContentType = "application/ms-excel"; } else if (DocumentType == "Word") { //Word .UrlEncode HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename + ".doc", System.Text.Encoding.UTF8)); HttpContext.Current.Response.ContentType = "application/ms-word"; } HttpContext.Current.Response.Charset = "GB2312"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); HttpContext.Current.Response.ContentType = "application/ms-excel"; HttpContext.Current.Response.Write(""); HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; //关闭控件的视图状态 source.Page.EnableViewState = false; //初始化HtmlWriter System.IO.StringWriter writer = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(writer); source.RenderControl(htmlWriter); //输出 HttpContext.Current.Response.Write(writer.ToString()); HttpContext.Current.Response.End(); }

我是这样导出的 所有的内容都可以 只有图片无法显示,求解决方法,谢谢!!急急!!

limina的主页 limina | 初学一级 | 园豆:158
提问于:2010-11-26 15:28
< >
分享
所有回答(2)
0

我博客里有个类库,可以操作WORD,能插入图片:

http://blog.csdn.net/durongjian/archive/2010/09/09/5873622.aspx

artwl | 园豆:16736 (专家六级) | 2010-11-26 15:34
博客中的类有行号,如果需要我晚上可以发给你一份整理好的!
支持(0) 反对(0) artwl | 园豆:16736 (专家六级) | 2010-11-26 17:27
0

直接输出是不可以了。

Astar | 园豆:40805 (高人七级) | 2010-11-27 07:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册