void Export(string format) { PrintingSystemBase ps = new PrintingSystemBase(); using (headerImage = Image.FromFile(Server.MapPath("~/Images/DevExpress-Logo-Large-Color.png"))) { LinkBase header = new LinkBase(); header.CreateDetailHeaderArea += Header_CreateDetailHeaderArea; PrintableComponentLinkBase link1 = new PrintableComponentLinkBase(); link1.Component = this.ASPxGridViewExporter1; link1.CreateReportFooterArea += Link1_CreateReportFooterArea; CompositeLinkBase compositeLink = new CompositeLinkBase(ps); compositeLink.Links.AddRange(new object[] { header, link1 }); compositeLink.CreateDocument(); using (MemoryStream stream = new MemoryStream()) { switch (format) { case "xls": compositeLink.ExportToXls(stream); WriteToResponse("filename", true, format, stream); break; case "pdf": compositeLink.ExportToPdf(stream); WriteToResponse("filename", true, format, stream); break; case "rtf": compositeLink.ExportToRtf(stream); WriteToResponse("filename", true, format, stream); break; default: break; } } ps.Dispose(); } }
protected void ExportButton_Click(object sender, EventArgs e) { PrintingSystemBase ps = new PrintingSystemBase(); PrintableComponentLinkBase link1 = new PrintableComponentLinkBase(ps); link1.Component = GridExporter1; PrintableComponentLinkBase link2 = new PrintableComponentLinkBase(ps); link2.Component = GridExporter2; CompositeLinkBase compositeLink = new CompositeLinkBase(ps); compositeLink.Links.AddRange(new object[] { link1, link2 }); compositeLink.CreateDocument(); using (MemoryStream stream = new MemoryStream()) { compositeLink.ExportToXls(stream); WriteToResponse("filename", true, "xls", stream); } ps.Dispose(); }