问题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都给分的,
都解答出来的我再追加给分,谢谢各位老大了~~~

解决方案 »

  1.   

    我的EMAIL是[email protected]
    高人发我邮件告诉我,我追加分数哦~~谢谢了~~~
      

  2.   


    一、定义文档类型、字符编码 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();  
      

  3.   

    3楼谢谢你,但是还是不能达到我想让他下载到默认c:\test目录下的要求
    难道没有高人知道吗??
      

  4.   

    设置客服端主机可以实现,不知是否有帮助.如下:
    打开我的电脑->工具->文件家选项->文件类型->选中word的扩展名"doc"或"docx"->高级->去掉"下载后确认打开"的勾选项.
      

  5.   

    打开,保存,取消,三个按钮是IE中的事件,似乎不能控制,六楼主方法倒是可行,但你的系统是WEB,不能对所有的客户IE进行设置哈,所以问题还是没法解决,
      

  6.   

    是啊,还是不行啊,哎...
    难道这真的无法解决了吗???
    高手们,来啊~~~求助求助~~~SOS~~~
      

  7.   

    打开WORD模板。添加图片数据。再在其他文件夹保存。
     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.
    参考
      

  8.   

    你只要把内容用文件流写到c盘不就ok了吗