日期:2014-05-19  浏览次数:20796 次

如何把label里有html格式的文字导出到一个word文档里,word里的文字要有label里的html格式?急~~很着急!!答对者50分
如何把label里有html格式的文字导出到一个word文档里,word里的文字要有label里的html格式

                public   static   void   tofiles(System.Web.HttpResponse   pa,   System.Web.UI.WebControls.Label   Label,   string   filename,   string   filetype)
                {
                        System.Web.HttpResponse   httpresponse   =   pa;

                        httpresponse.ContentEncoding   =   System.Text.Encoding.GetEncoding( "gb2312 ");
                        if   (filetype   ==   "0 ")
                        {
                                httpresponse.AppendHeader( "content-disposition ",   "attachment;filename= "   +   HttpUtility.UrlEncode(filename,   System.Text.Encoding.UTF8)   +   ".doc ");   //filename= "*.doc ";  
                                httpresponse.ContentType   =   "application/msword ";
                        }
                        else
                        {
                                httpresponse.AppendHeader( "content-disposition ",   "attachment;filename= "   +   HttpUtility.UrlEncode(filename,   System.Text.Encoding.UTF8)   +   ".xls ");   //filename= "*xls ";  
                                httpresponse.ContentType   =   "application/ms-excel ";
                        }
                        System.IO.StringWriter   sw   =   new   System.IO.StringWriter();
                        System.Web.UI.HtmlTextWriter   hw   =   new   System.Web.UI.HtmlTextWriter(sw);
                        HttpUtility.HtmlEncode(Label.Text,   hw);

                        //hw.Write(a);

                        httpresponse.Output.Write(HttpUtility.HtmlDecode(sw.ToString()));
                        httpresponse.End();
                }


这是我写的类,实在搞不出来了,要是有人知道,我给50分

------解决方案--------------------
HttpUtility.HtmlEncode( " <html> " + Label.