Skip to content

DevExpress-Examples/asp-net-web-forms-export-several-controls-to-different-sheets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ASP.NET Web Forms - How to export several controls to different XLSX worksheets

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

Does this example address your development requirements/objectives?

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