public override void ProcessRequest(HttpContext context) { switch (context.Request.QueryString["editMode"]) { case "download": { SOARole role = PrepareRole(this.RoleID, this.DefinitionID); WorkBook workBook = role.ToExcelWorkBook(); context.Response.CacheControl = "no-cache"; context.Response.AppendExcelOpenXmlHeader("matrix"); workBook.Save(context.Response.OutputStream); context.Response.Flush(); } break; case "readOnly": Server.Execute("~/MatrixModalDialog/DownloadMatrix.aspx", true); break; default: base.ProcessRequest(context); break; } }
protected void RolePropertyEdit_PrepareDownloadStream(object sender, PrepareDownloadStreamEventArgs args) { string[] itemsInfo = args.DownloadInfo.RequestContext.Split(';'); string roleID = itemsInfo[1]; string defID = itemsInfo[2]; SOARole role = PrepareRole(roleID, defID); WorkBook workBook = role.ToExcelWorkBook(); using (MemoryStream stream = new MemoryStream()) { workBook.Save(stream); stream.Seek(0, SeekOrigin.Begin); stream.CopyTo(args.OutputStream); } }