protected void btnExport_Click(object sender, EventArgs e) { ExcelPackage package = new ExcelPackage(); EppTools tools = new EppTools(); // string fileName = "SalesReport"; //string year = ddlYear.SelectedValue; string dateFrom = tbStart.Text.Trim(); string dateTo = tbEnd.Text.Trim(); dateFrom = dateFrom != string.Empty ? dateFrom : "all"; dateTo = dateTo != string.Empty ? dateTo : "all"; int kiosk = Convert.ToInt32(ddlKiosk.SelectedItem.Value); DataTable table = Common.GetSalesReport(dateFrom, dateTo, kiosk); // tools.GenerateSalesReport(table, ref package, fileName); // var ws = package.Workbook.Worksheets[fileName]; // // HEADER TITLE FORMATING ws.Cells[2, 1].Value = "SALES REPORT "; ws.Cells[3, 1].Value = "Date From: " + dateFrom + " To: " + dateTo; 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; ws.Cells[6, 9].Value = "PRICE #"; ws.Cells[6, 8].Style.Font.Bold = true; // SAVING EXCEL FILE Response.Clear(); Response.BinaryWrite(package.GetAsByteArray()); Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", "attachment; filename=\"" + "Sales_Report_" + dateFrom + "_" + dateTo + ".xlsx\""); Response.Flush(); Response.End(); package = null; ws = null; // }
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; }