1,VSTO
2,PIA
3,OpenXML
Aspose.Word,可以预先用word定义模板,插入各种mergefield,利用Aspose.Word生成最终word。
你在数据库存 Word文件名
使用 webOffice 实现在线编辑,写保护,在线保存等功能
http://www.cnblogs.com/dooom/archive/2010/07/03/1770450.html
这边相关实例
上面答的都对,如果你只是简单的将一些文本或者HTML格式输出到DOC里,可以使用:
protected void Button1_Click(object sender, EventArgs e)
{
Export("application/ms-word", "员工报表.doc");
}
private void Export(string FileType, string FileName)
{
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
GridView1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}