protected void toExcelButton_Click(object sender, EventArgs e) { if (TemplateList.SelectedIndex == 0 || TemplateList.SelectedIndex == -1) { return; } Teleform.Reporting.Template template = Storage.Select <Template>(TemplateList.SelectedValue); var dt = Global.GetDataTable("EXEC [report].[getCubeByTemplate] " + TemplateList.SelectedValue); string file = template.Name; using (var stream = new MemoryStream()) { //var builder = new CrossReportExcelBuilder(); //var builder = new ExcelReportBuilder(); var builder = new CrossTemplateExcelBuilder(); List <string> headerList = new List <string>(); var groupReport = Make(template, dt, ref headerList); builder.HeaderList = headerList; builder.Create(stream, groupReport); Response.Clear(); Response.ContentType = "text/html"; Response.AddHeader("content-disposition", string.Format("attachment;fileName={0}.xlsx", file)); Response.ContentEncoding = Encoding.UTF8; Response.BinaryWrite(stream.ToArray()); Response.Flush(); Response.End(); } }
public ExcelReport(Template template, string sheet, IEnumerable <Instance> instances) : base(template, instances) { Sheet = sheet; }