private void ExportMatrixData() { WfMatrix matrix = WfMatrixAdapter.Instance.Load(this.ExportKey); matrix.Loaded = true; switch (this.ExFormat) { case ExportFormat.Xlsx: Response.Clear(); Response.ClearHeaders(); using (MemoryStream fileSteam = matrix.ExportToExcel2007(this.RoleAsPerson)) { fileSteam.CopyTo(Response.OutputStream); } //Response.BinaryWrite(bytes); //Response.ContentType = MediaTypeNames.Text.Xml; Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AppendHeader("CONTENT-DISPOSITION", "attachment;filename=" + matrix.ProcessKey + ".xlsx"); Response.Flush(); Response.End(); break; case ExportFormat.Xml: WorkbookNode workbook = matrix.ExportToExcelXml(this.RoleAsPerson); workbook.Response(matrix.ProcessKey); break; } }
protected void materialCtrl_PrepareDownloadStream(object sender, PrepareDownloadStreamEventArgs args) { bool roleAsPerson = false; string[] itemsInfio = args.DownloadInfo.RequestContext.Split(';'); Boolean.TryParse(itemsInfio[1], out roleAsPerson); string downloadkey = itemsInfio[0]; WfMatrix matrix = WfMatrixAdapter.Instance.Load(downloadkey); matrix.Loaded = true; using (MemoryStream excelStream = matrix.ExportToExcel2007(roleAsPerson)) { excelStream.CopyTo(args.OutputStream); } }