Nilesh Makwana

Nilesh Makwana

  • 1.4k
  • 368
  • 11.7k

Export Excel from Database in Asp.Net MVC using partial view

Aug 23 2018 9:26 AM
hi, 
 
i want to export(Create) and Downlod excel file from database in ASP.NET MVC  ,anddownlod button is in partial view(is in popup) but it is not working and not show any error,,iam use ExcelPackage and create two datatable and combine customize cell ,, in worksheet
 
HttpContext.Response.Clear();
HttpContext.Response.AddHeader("", "");
HttpContext.Response.Charset = System.Text.UTF8Encoding.UTF8.WebName;
HttpContext.Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
HttpContext.Response.AddHeader("content-disposition", "attachment;
filename=filename.xlsx);
HttpContext.Response.ContentType = "application/excel";
HttpContext.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
HttpContext.Response.BinaryWrite(excel.GetAsByteArray());
HttpContext.Response.End();
is not working 

Answers (4)