读书人

怎么将html里的内容写入word

发布时间: 2012-12-16 12:02:32 作者: rapoo

如何将html里的内容写入word?
如何将html里的内容写入word?请高手给点思路
[最优解释]
参考

http://blog.csdn.net/educast/article/details/4420111
里面的SaveOrOutData方法

[其他解释]
//重写此事件,防止从gridview导出到excel时报错。
public override void VerifyRenderingInServerForm(Control control)
{
//base.VerifyRenderingInServerForm(control);
}
public void Export(string FileType, string FileName)
{
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
Repeater1.RenderControl(hw);
string str = hw.InnerWriter.ToString();
Response.Write(sw.ToString());
Response.End();
}



调用:
Export("application/ms-word", "word.doc");
[其他解释]
最简单的方法改后缀名,word打开时会自动转换的

读书人网 >asp.net

热点推荐