System.IO.StringWriter sw = new System.IO.StringWriter();
        System.Web.UI.Html32TextWriter htw = new Html32TextWriter(sw);
        //导出对象
        this.Label1.Text = "<center>";
        Label1.RenderControl(htw);
        //以表格形式显示
        Label1.Text = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0px\" >";
        Label1.RenderControl(htw);
        //显示第0行
         Label1.Text = "<tr><td colspan=\"3\" align=\"left\" style=\"padding-left:2px;padding-  top:5px;                         padding-bottom:5px\"><img src=\"../images/new1.gif\" /></td></tr>";
        Label1.RenderControl(htw);        this.Label1.Text = "</table></center>";
        Label1.RenderControl(htw);
        //清除缓冲区,设置输出为word
        Response.Buffer = true;
        Response.Clear();
        Response.ClearContent();
        Response.ClearHeaders();
        Response.ContentType = "Response.ContentType";
        Response.Charset = "utf-8";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
        Response.AddHeader("Content-Disposition", "attachment;filename="+name+".doc");
        Response.Write(sw.ToString());
        Response.Flush();
        Response.Close();

解决方案 »

  1.   

    代码问题  参考:
    (1)创建一个Windows控制台应用程序,命名为CreatePicDemo。(2)添加对Microsoft Word 12.0 Object Library的引用(word2007/03为11.0)。(3)在“Program.cs”文件中添加如下引用。using MSWord = Microsoft.Office.Interop.Word;using System.IO;using System.Reflection;(4)直接修改“Program.cs”文件的代码如下。class Program{    static void Main(string[] args)    {        object path;                                   string strContent;                                 MSWord.Application wordApp;                     MSWord.Document wordDoc;                     path = @"C:\MyWord.docx";               wordApp = new MSWord.ApplicationClass();        //如果已存在,则删除        if (File.Exists((string)path))        {            File.Delete((string)path);        }        Object Nothing = Missing.Value;        wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);        //图片文件的路径        string filename = @"C:\BackgroundImage.jpg";
            Object range = wordDoc.Paragraphs.Last.Range;        //定义该插入的图片是否为外部链接        Object linkToFile = false;                       Object saveWithDocument = true;                 wordDoc.InlineShapes.AddPicture(filename, ref linkToFile, ref saveWithDocument, ref range);        object format = MSWord.WdSaveFormat.wdFormatDocumentDefault;        wordDoc.SaveAs(ref path, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);        wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);        wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);        Console.WriteLine(path + " 创建完毕!");    }}
      

  2.   

    谢谢yilanwuyu123了,你提供了一个思路,我解决了