导出word问题

swich 2004-08-30 04:02:14
有个table

如何导出成word文件

谢谢,急
...全文
251 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
swich 2004-08-31
  • 打赏
  • 举报
回复
怎么没人回答啊
swich 2004-08-31
  • 打赏
  • 举报
回复
up
swich 2004-08-30
  • 打赏
  • 举报
回复
up
hareqiqi 2004-08-30
  • 打赏
  • 举报
回复
将html代码存为.doc就可以了。
swich 2004-08-30
  • 打赏
  • 举报
回复
能给个具体得例子吗
swich 2004-08-30
  • 打赏
  • 举报
回复
up
swich 2004-08-30
  • 打赏
  • 举报
回复
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=RoadRepair.doc");
这行出错,

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30037: Character is not valid.

大家帮忙
lwbmail 2004-08-30
  • 打赏
  • 举报
回复
table属于一个前台控件,如果楼主是在后台写代码的话,table是不能直接进行导出Word的,必须将table放到一个Panel控件里,然后在后台征对Panel写导出Word的代码。

这只是本人的一个小小的建议,前台的导出我还没有做过,呵呵,路过~~

caoit 2004-08-30
  • 打赏
  • 举报
回复
strFileName = strFileName.Trim() + DateTime.Today.ToString("yyyyMMdd") + ".doc";
page.Response.Clear();
page.Response.Buffer= true;
page.Response.AppendHeader("Content-Disposition", "Attachment;fileName=" + strFileName );
page.Response.ContentType = "application/vnd.ms-word";
page.Response.Charset = "";
page.EnableViewState = false;
StringWriter oStringWriter = new StringWriter();
HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);
dgExcel.RenderControl(oHtmlTextWriter);
page.Response.Write(oStringWriter.ToString());
page.Response.End();
wnlovezxm 2004-08-30
  • 打赏
  • 举报
回复
owc!
swich 2004-08-30
  • 打赏
  • 举报
回复
我试试看谢谢
ckvip 2004-08-30
  • 打赏
  • 举报
回复
我这里是将一个datagrid导出为word,您只要把代码中的datagrid1换成您的table就可以了
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=RoadRepair.doc");
Response.ContentType = "application/vnd.ms-word" ;//指定生成文件的类型
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
DataGrid1.Page.EnableViewState = false;
System.IO.StringWriter tw=new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw=new System.Web.UI.HtmlTextWriter(tw);
DataGrid1.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
swich 2004-08-30
  • 打赏
  • 举报
回复
我得要求是按一个按钮使之生成一个word文件,老大帮忙
孟子E章 2004-08-30
  • 打赏
  • 举报
回复
Response.ContentType = "Application/msword"即可
swich 2004-08-30
  • 打赏
  • 举报
回复
up

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧