first create a excel file in your local system as well as in your project then take a download link button and write following code
protected void LinkButton1_Click(object sender, EventArgs e)
{
string fileName = "test.xlsx";
string filePath = Server.MapPath("~/test.xlsx");
Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=" + fileName);
Response.ContentType = "application/octet-stream";
Response.WriteFile(filePath);
Response.Flush();
Response.End();
}
It will display like
Thanks
shibashish mohanty
protected void LinkButton1_Click(object sender, EventArgs e)
{
string fileName = "test.xlsx";
string filePath = Server.MapPath("~/test.xlsx");
Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=" + fileName);
Response.ContentType = "application/octet-stream";
Response.WriteFile(filePath);
Response.Flush();
Response.End();
}
It will display like
Thanks
shibashish mohanty
No comments:
Post a Comment
Please don't spam, spam comments is not allowed here.