求一个用asp.net打开word的完整案例
越详细越好,用于菜鸟学习,求各位大神帮忙! ASP.NET Word --------------------编程问答-------------------- 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();
}
--------------------编程问答-------------------- GridView1.RenderControl(hw);
这句一直提示:类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内。
可是我.aspx中的内容是:
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<br />
</div>
</form>
</body> --------------------编程问答-------------------- 建议用vba,方便多了。
刚刚做过这么个安全。 --------------------编程问答-------------------- asp.net打开word的神器是PageOffice,这个是专业的第三方组件,服务器端不用安装office,不用自动化调用,不仅可以动态输出任何你要的内容到word文档里,还可以在网页里在线显示、编辑word、excel。你不用担心浏览器兼容问题,PageOffice支持IE、chrome、firefox、搜狗、遨游、360等所有流行的浏览器 --------------------编程问答-------------------- 建议楼主查询下 Aspose.words 这个第三方控件,可以输出word,读取word,另存为html ,等等。功能非常强悍。
补充:.NET技术 , ASP.NET