因为我的DateGrid里含有超链接及分页,所以不能直接导Excel,我是用写代码自己一行一行导入Excel的,现在已导成功功,但数据是保存在服务器的电脑上的,请问如何能过下载到客户端?

解决方案 »

  1.   

    string name="d:\\abc.xls";
    System.IO.FileInfo aFile=new System.IO.FileInfo(name);
    string na=Path.GetFileName(name);
    Response.Clear();
    Response.ClearHeaders();
    Response.BufferOutput=false;
    Response.ContentType="application/octet-stream";
    Response.AddHeader("Content-Disposition","attachment;filename="+na);
    Response.AddHeader("Content-Length",aFile.Length.ToString());
    Response.WriteFile(name);
    Response.Flush();
    Response.End();
      

  2.   

    Response.ContentType = "application/ms-excel";
      

  3.   

    楼上的正确,意思是把一个文件下载,即使是asp文件也可以
      

  4.   

    http://community.csdn.net/Expert/topic/3451/3451639.xml?temp=.693722
    楼上的正确.