读书人

-Asp.Net怎么将网页及图片一并导出到W

发布时间: 2012-04-15 18:39:21 作者: rapoo

------------Asp.Net如何将网页及图片一并导出到Word中?----------
目前可以实现非图片的导出,如果网页中有图片到Word中就是一个红叉,请问如何解决?

以下是导出代码:

C# code
    //功能实现    public static void ToWord(System.Web.UI.Control ctl)    {        HttpContext.Current.Response.Clear();        HttpContext.Current.Response.Charset = "";        HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=DocLibrary.doc");        HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");        HttpContext.Current.Response.ContentType = "application/ms-word";        ctl.Page.EnableViewState = false;        System.IO.StringWriter tw = new System.IO.StringWriter();        System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);        ctl.RenderControl(hw);        HttpContext.Current.Response.Write(tw.ToString());        HttpContext.Current.Response.End();    }    //调用    Tools.ToWord(this.div1);


[解决办法]
试下这个:
http://blog.csdn.net/Leeu/archive/2005/04/09/340735.aspx
[解决办法]
直接打开WORD模版,addpicture添加图片
mydoc.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture("C:\\test.jpg", ref oMissing, ref oMissing, ref oMissing);

书签绑定数据
或方法不变,使用HTML保存数据
[解决办法]
探讨

直接打开WORD模版,addpicture添加图片
mydoc.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture("C:\\test.jpg", ref oMissing, ref oMissing, ref oMissing);

书签绑定数据
或方法不变,使用HTML保存数据

[解决办法]
探讨

刚刚发现一个东西(SOAOffice)估计可以解决我的问题,不过是付费的,郁闷!!

继续摸搜。。。

读书人网 >asp.net

热点推荐