Skip to content

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

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Export several components to different worksheets of the same document.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • ASP.NET 59.4%
  • C# 21.6%
  • Visual Basic .NET 19.0%