【备忘】html标记布局文本保存到word
net吧
全部回复
仅看楼主
level 2
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">
<!-- 富文本代码区 -->
</html>
在含有html标记的字符串首尾添加上述引用;
后台代码:
//保存到Word
//设置Http的头信息,编码格式
Response.AppendHeader("Content-Disposition", "attachment;filename=“+strName+”.doc");
Response.ContentType = "application/ms-word";
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.UTF8;
//初始化HtmlWriter
System.IO.StringWriter writer = new System.IO.StringWriter();
writer.Write(Server.HtmlDecode(sbPartText.ToString()));
Response.Write(writer.ToString());
Response.End();
2016年05月10日 07点05分 1
1