protected void btnExport_Click(object sender, EventArgs e) { ExcelPackage package = new ExcelPackage(); EppTools tools = new EppTools(); // string fileName = "WeeklyReport"; string year = ddlYear.SelectedValue; int classid = Convert.ToInt32(ddlClass.SelectedItem.Value); DataTable table = Common.GetDailyReport(year, classid); // tools.GenerateDailyReport(table, ref package, fileName); // var ws = package.Workbook.Worksheets[fileName]; // // HEADER TITLE FORMATING ws.Cells[2, 1].Value = "DAILY REPORT "; ws.Cells[3, 1].Value = "Year and Date "; ws.Cells[4, 1].Value = "Agent: " + GlobalAccess.Username; ws.Cells[2, 1, 4, 1].Style.Font.Bold = true; ws.Cells[2, 1, 4, 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left; // SAVING EXCEL FILE Response.Clear(); Response.BinaryWrite(package.GetAsByteArray()); Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", "attachment; filename=\"" + "Daily_Report.xlsx\""); Response.Flush(); Response.End(); package = null; ws = null; }