求一个用asp.net打开word的完整案例 ASP.NETWord 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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 ,等等。功能非常强悍。 asp.net Office文件在线转换swf的问题 请教数据库连接问题 asp.net页面客户端调用outlook 文件下载格式问题 正则问题小问题 没分了 有分补. Regex简单问题. 强大的Spread表格控件 高分请教:急:动态创建的模板列,如何得到其下拉列表框选择的值。动态创建了8列,为何其列数没有增加8。●●●● 如何在DropDownList内实现树型结构? 在asp.net中读取下一条数据是怎么写的? 怎么样把一个PPT放在网页上显示 调用dsoframer.ocx出错
{
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();
}
这句一直提示:类型“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>
刚刚做过这么个安全。