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

把Label中的内容保存到.doc文件,不要</span>的标记,要怎么做呢?
按照导出gridview的方法,倒出来的文档是这样的:
<span   id= "Label1 "> 112233444 </span>

如果我要去掉 <span   id= "Label1 "> </span> 的标记,只要112233444,怎么实现呢?

谢谢大家

我的类的代码:

                ///   grid转word
                ///   </summary>
                ///   <param   name= "pa "> 页面HttpResponse输入 </param>
                ///   <param   name= "gridview "> 传入需要生成excel的gridview </param>
                ///   <param   name= "filename "> 生成的文件名 </param>
                ///   <param   name= "path "> 生成的地址 </param>
                public   static   void   toword(System.Web.HttpResponse   pa,   System.Web.UI.WebControls.Label   Label1,   string   filename,   string   path)
                {
                        System.Web.HttpResponse   httpresponse   =   pa;
                        httpresponse.AppendHeader( "content-disposition ",   "attachment;filename= "   +   HttpUtility.UrlEncode(filename,   System.Text.Encoding.UTF8));   //filename= "*.doc ";  
                        httpresponse.ContentEncoding   =   System.Text.Encoding.GetEncoding( "gb2312 ");
                        httpresponse.ContentType   =   "application/msword ";
                        System.IO.StringWriter   tw   =   new   System.IO.StringWriter();
                        System.Web.UI.HtmlTextWriter   hw   =   new   System.Web.UI.HtmlTextWriter(tw);
                        Label1.RenderControl(hw);

                        string   filepath   =   path   +   filename;
                        System.IO.StreamWriter   sw   =   System.IO.File.CreateText(filepath);
                        sw.Write(tw.ToString());
                        sw.Close();

                        httpresponse.End();
                }

------解决方案--------------------
up再说
------解决方案--------------------
不要用Label
请用Literal