请问asp.net如何将整个页面或部分页面导出到word?并下载到本地?
展开全部
//EnableEventValidation="false" //页面上的设定
Response.ContentType = "application/ms-word";//指定到word
Response.AddHeader("Content-Disposition", "inline;filename=test.doc");
StringBuilder sb = new StringBuilder();//没用上
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
sb.Append("");//没用上
pnlToWord.RenderControl(hw);//指定一个区域pnlToWord是Panel控件
//Page.RenderControl(hw);//整个页面
Response.Write(sw.ToString());
Response.End();
Response.ContentType = "application/ms-word";//指定到word
Response.AddHeader("Content-Disposition", "inline;filename=test.doc");
StringBuilder sb = new StringBuilder();//没用上
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
sb.Append("");//没用上
pnlToWord.RenderControl(hw);//指定一个区域pnlToWord是Panel控件
//Page.RenderControl(hw);//整个页面
Response.Write(sw.ToString());
Response.End();
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询