当前位置:编程学习 > C#/ASP.NET >>

求助求助 excel 服务器下载到本地 B/s



 file = file + ".xls";

这个file 就是导出在服务器上文件夹下面的路径
怎么样下载到本地系统  咋整啊 
excel file --------------------编程问答-------------------- 自己写个程序读你上传到的指定文件夹下的文件。提供下载就可以了 --------------------编程问答-------------------- 直接window.open(地址)
或者
  System.IO.FileInfo file = new System.IO.FileInfo(save_path);
  Response.Clear();
  Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8));   
  Response.AddHeader("Content-Length", file.Length.ToString());
  //Response.ContentType = "application/octet-stream";
  Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
  Response.WriteFile(file.FullName);
  Response.End();
--------------------编程问答--------------------
引用 2 楼 wbloveilove 的回复:
直接window.open(地址)
或者
C# code?12345678  System.IO.FileInfo file = new System.IO.FileInfo(save_path);  Response.Clear();  Response.AddHeader("Content-Disposition", "attachment;filename=" ……


  file = file + ".xls";
                if (file != "")
                {

                    string path = file;

                    System.IO.FileInfo files = new System.IO.FileInfo(path);

                    if (files.Exists)
                    {
                        Response.Clear();
                        Response.AddHeader("Content-Disposition", "attachment; filename=" + files.Name);
                        Response.AddHeader("Content-Length", files.Length.ToString());
                        Response.ContentType = "application/octet-stream";
                        Response.Filter.Close();
                        Response.WriteFile(file);
                        Response.End();
                    }
                    else
                    {
                        Response.Write("This file does not exist.");
                    }
                }
                //强制对所有代进行垃圾回收
                GC.Collect();


我这样写的 但是还有问题  没有反应
报这个异常 不知道什么意思

由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值。 --------------------编程问答-------------------- 如果只是excel文件的话直接a标签href属性写成文件地址就可以下载 --------------------编程问答--------------------
引用 4 楼 zhiaiyahong 的回复:
如果只是excel文件的话直接a标签href属性写成文件地址就可以下载

怎么写法 不是很明白,,是只是excel文件 导出的文件  放在file 这个目录下  
怎么写的啊  --------------------编程问答--------------------
引用 1 楼 ly_sl 的回复:
自己写个程序读你上传到的指定文件夹下的文件。提供下载就可以了

怎么写啊  问题是不知道写啊 --------------------编程问答--------------------
引用 5 楼 LEE_CM 的回复:
引用 4 楼 zhiaiyahong 的回复:
如果只是excel文件的话直接a标签href属性写成文件地址就可以下载
怎么写法 不是很明白,,是只是excel文件 导出的文件  放在file 这个目录下  
怎么写的啊
<a href="file/我是表.xls">下载<a>
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,