0

Sorry to ask a very basic question, i'm new to ASP.NET. I just want to know how to save a downloaded excel to a specific folder. Here is my code to download the excel sheet.

    public void ExcelForMonthlyReport(DateTime? startDate, DateTime? endDate)
    {
        MonthlyReportExcel excelMonthlyReport = new MonthlyReportExcel();//This class has all excel formating.
        Response.ClearContent();
        Response.BinaryWrite(excelMonthlyReport.GenerateMonthlyReport(GeMonthlyUploadData(startDate, endDate)));//method which gives data for excelsheet.
        Response.AppendHeader("content-disposition", $"attachment; filename = Monthly Report {DateTime.Now:yyyy-MM-dd - HH.mm.ss}.xlsx");
        Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        Response.Flush();
        Response.End();
    }
Ajay Managaon
  • 450
  • 2
  • 9

0 Answers0