问题描述
用CKeditor编辑过的文本,带有html标签如/br<p>,导出word时直接输出了,word不能识别怎么处理,各位大神帮帮忙
解决方案
解决方案二:
///<summary>///清除HTML标记///</summary>///<paramname="NoHTML">包括HTML的源码</param>///<returns>已经去除后的文字</returns>publicstaticstringNoHTML(stringHtmlstring){//删除脚本Htmlstring=Regex.Replace(Htmlstring,@"<script[^>]*?>.*?</script>","",RegexOptions.IgnoreCase);//删除HTMLRegexregex=newRegex("<.+?>",RegexOptions.IgnoreCase);Htmlstring=regex.Replace(Htmlstring,"");Htmlstring=Regex.Replace(Htmlstring,@"<(.[^>]*)>","",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"([rn])[s]+","",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"-->","",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"<!--.*","",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"&(quot|#34);",""",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"&(amp|#38);","&",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"&(lt|#60);","<",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"&(gt|#62);",">",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"&(nbsp|#160);","",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"&(iexcl|#161);","xa1",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"&(cent|#162);","xa2",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"&(pound|#163);","xa3",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"&(copy|#169);","xa9",RegexOptions.IgnoreCase);Htmlstring=Regex.Replace(Htmlstring,@"&#(d+);","",RegexOptions.IgnoreCase);Htmlstring.Replace("<","");Htmlstring.Replace(">","");Htmlstring.Replace("rn","");returnHtmlstring;}
解决方案三:
likofans大神,这段代码应该只是把html标签去掉了,但我想要的是word能识别这些html标签,比如html本文是“6400m<sup>3</sup>/h”,我想导到word中变成6400m³/h
解决方案四:
各位大神帮帮忙,分不够可在加,客户催的急,哪位好心人能帮帮我阿
解决方案五:
楼主解决了吗?我也遇到了相同的问题。