Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 3.4 KB

File metadata and controls

57 lines (40 loc) · 3.4 KB

Web Forms - How to export several controls to different XLSX worksheets

[Run Online]

This example illustrates how to export several components to different worksheets of the same XLSX document.

Exported Document

In this example, the page contains 3 components: ASPxGridView, ASPxTreeList, and WebChartControl. You can export them to different worksheets of the same document in the following way:

  1. Create a PrintableComponentLinkBase object for every component.

    PrintableComponentLinkBase link1 = new PrintableComponentLinkBase(ps);
    link1.Component = Grid;
    
    PrintableComponentLinkBase link2 = new PrintableComponentLinkBase(ps);
    link2.Component = Tree;
    
    PrintableComponentLinkBase link3 = new PrintableComponentLinkBase(ps);
    Chart.DataBind();
    link3.Component = ((IChartContainer)Chart).Chart;
  2. Call the CreatePageForEachLink method to create a separate page for every component.

    CompositeLinkBase compositeLink = new CompositeLinkBase(ps);
    compositeLink.Links.AddRange(new object[] { link1, link2, link3 });
    compositeLink.CreatePageForEachLink();
  3. Create an XlsxExportOptions object and set its ExportMode property to SingleFilePageByPage value to export a document to a single file, page-by-page. Send the options to the ExportToXlsx method to export the document.

    XlsxExportOptions options = new XlsxExportOptions();
    options.ExportMode = XlsxExportMode.SingleFilePageByPage;
    compositeLink.PrintingSystemBase.ExportToXlsx(stream, options);

Files to Review

More Examples