如何下载示例excel文件: [英] How to download a sample excel file:

查看:81
本文介绍了如何下载示例excel文件:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个下载应用程序,以便用户需要下载一个示例excel文件并需要保存在他的首选目录中....可以帮助吗?

解决方案

http:// www.c-sharpcorner.com/UploadFile/0c1bb2/uploading-and-downloading-excel-files-from-database-using-as/ [ ^ ]

http:/ /weblogs.asp.net/rajbk/archive/2010/02/20/uploading-and-storing-files-in-sql-using-asp-net.aspx [ ^ ]

public void filedownloadcode(string filename)

{

try

{

string strURL = filename;

WebClient req = new WebClient();

HttpResponse response = HttpContext.Current.Response;

response.Clear ();

response.ClearContent();

response.ClearHeaders();

response.Buffer = true;

response.AddHeader(Content-Disposition,attachment; filename = \+ Server.MapPath(strURL)+\);

byte [] data = req.DownloadData(Server.MapPath(strURL));

response.BinaryWrite(data);

response.End();

}

catch(例外情况)

{





}

}


I want to develop a download application so that the user need to download a sample excel file and need to save in his preferred directory....can any one help?

解决方案

http://www.c-sharpcorner.com/UploadFile/0c1bb2/uploading-and-downloading-excel-files-from-database-using-as/[^]
http://weblogs.asp.net/rajbk/archive/2010/02/20/uploading-and-storing-files-in-sql-using-asp-net.aspx[^]


public void filedownloadcode(string filename)
{
try
{
string strURL = filename;
WebClient req = new WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.MapPath(strURL) + "\"");
byte[] data = req.DownloadData(Server.MapPath(strURL));
response.BinaryWrite(data);
response.End();
}
catch (Exception ex)
{


}
}


这篇关于如何下载示例excel文件:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆