Skip to content

DevExpress-Examples/asp-net-web-forms-export-pivot-grid-and-chart-in-one-document

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ASP.NET Web Forms - How to export ASPxPivotGrid and bound WebChartControl to the same print document

This example demonstrates how to combine several ASP.NET controls in one exported document. This project shows how to apply this solution to ASPxPivotGrid and WebChartControl, but it is also applicable to other components that implement the IPrintable and IBasePrintable interfaces.

Note

This example uses the Printing.Core library. Make sure that you include it in your project.

Implementation Details

  1. Create a PrintableComponentLinkBase object for each exported component.
  2. Specify the PrintableComponentLinkBase.Component property.
  3. Create a CompositeLinkBase object to combine several printing links.
  4. Add PrintableComponentLinkBase objects to the CompositeLinkBase.Links collection.
  5. Call the CompositeLinkBase.ExportTo[FORMAT] method to export the document.
PrintingSystemBase ps = new PrintingSystemBase();
ps.ExportOptions.Pdf.DocumentOptions.Author = "Test";

PrintableComponentLinkBase link1 = new PrintableComponentLinkBase(ps);
link1.Component = ASPxPivotGridExporter1;

PrintableComponentLinkBase link2 = new PrintableComponentLinkBase(ps);
WebChartControl1.DataBind();
link2.Component = ((IChartContainer)WebChartControl1).Chart;

CompositeLinkBase compositeLink = new CompositeLinkBase(ps);
compositeLink.Links.AddRange(new object[] { link1, link2 });

using (MemoryStream stream = new MemoryStream()) {
    compositeLink.ExportToPdf(stream);
    Response.Clear();
    Response.Buffer = false;
    Response.AppendHeader("Content-Type", "application/pdf");
    Response.AppendHeader("Content-Transfer-Encoding", "binary");
    Response.AppendHeader("Content-Disposition", "attachment; filename=test.pdf");
    Response.BinaryWrite(stream.ToArray());
    Response.End();
}

ps.Dispose();

Files to Review

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Combine ASPxPivotGrid and WebChartControl in one exported document.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •