问题1:
HTML以Word流形式输出并保存至本地,如何取消提示下载对话框,直接下载到默认目录?Response.Clear();
Response.Buffer = true;
Response.Charset = "gb2312";
//Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.AddHeader("Content-Disposition", "attachment;filename=expert.doc");
Response.ContentType = "application/ms-word";
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
Label1.Width = 560;
Label1.RenderControl(oHtmlTextWriter);
Response.Output.Write(oStringWriter.ToString());
Response.Flush();
Response.End();上述代码实现了,将声成的页面以Word形式保存至本地磁盘,但是运行过程中,总免不了出现
-----------------------
| 打开 保存 取消|
-----------------------
这个对话框,请问有什么办法可以取消这个对话框吗?而直接下载到c:\test\1.doc
我用的是vs2008,生成页面是asp.net中的repeater控件绑定数据库问题2:
网页生成中,发布在浏览器中的文件可以出现我c:\test\1.gif这个图片文件
但是当用上述方法保存至Word文档图片的位置就是个“红XX”
如何能把我本地的图片通过问题1中的方式直接输出到Word中呢?各位老大,这个问题困扰好久了,希望有强人帮忙解决,小弟一定给分多多。
解答对问题1或者问题2都给分的,
都解答出来的我再追加给分,谢谢各位老大了~~~
解决方案 »
- 大家帮看看这个思路,邮件系统能不能这样设计?
- 懂E-R图的请进200分送上
- asp.net(C#) 未将对象引用设置到对象的实例
- 呼叫中心,有了解这方面资料的吗给点,想做这方面的东西
- update问题,我都急得不行,请哪位高手指点,在线等!!!!!!!!!
- 一个关于事务与封锁的问题.
- 如何知道页面的控件结构,
- full join是什么意思?full join和full outer join有什么区别?有outer和没outer的链接有什么不同?
- .net一个奇异的问题
- 复制excel带边框的表格到kindEditor编辑器里,不显示边框
- 急救,遍历fileupload问题,高手赐教!!
- 简单注册模块的生日代码和性别代码
高人发我邮件告诉我,我追加分数哦~~谢谢了~~~
一、定义文档类型、字符编码 Response.Clear();
Response.Buffer= true;
Response.Charset="utf-8"; //下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开 //filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc || .xls || .txt ||.htm Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8"); //Response.ContentType指定文件类型 可以为application/ms-excel || application/ms-word || application/ms-txt || application/ms-html || 或其他浏览器可直接支持文档 Response.ContentType = "application/ms-excel";
this.EnableViewState = false; 二、定义一个输入流 System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); 三、将目标数据绑定到输入流输出 this.RenderControl(oHtmlTextWriter); //this 表示输出本页,你也可以绑定datagrid,或其他支持obj.RenderControl()属性的控件 Response.Write(oStringWriter.ToString());
Response.End();
难道没有高人知道吗??
打开我的电脑->工具->文件家选项->文件类型->选中word的扩展名"doc"或"docx"->高级->去掉"下载后确认打开"的勾选项.
难道这真的无法解决了吗???
高手们,来啊~~~求助求助~~~SOS~~~
Word.Shape oShape= wordDoc.Shapes.AddPicture("D:\\a.gif",ref Nothing,ref objt,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing);
oShape.WrapFormat.Type =Word.WdWrapType.wdWrapSquare;
添加图片到文件夹
再打开word.
参考