How to Export Data to Excel with Multiple Sheets in Pega using pxGenerateExcelFile

This article demonstrates how to export data from Pega to an Excel file containing multiple sheets using the OOTB activity pxGenerateExcelFile combined with a PageGroup and PageLists. This approach allows each Excel sheet to display different sets of data from the same case.

Architecture / Approach

PageGroup (e.g., ExcelData)
├── PageList 1 → Properties (Col1, Col2, Col3…) → Sheet 1
├── PageList 2 → Properties (Col1, Col2, Col3…) → Sheet 2
└── PageList 3 → Properties (Col1, Col2, Col3…) → Sheet 3

Step-by-Step Implementation

  1. Create the PageGroup and PageLists
  • Define a PageGroup property (e.g., ExcelData) on your case type

  • Under the PageGroup, define 3 PageList properties — one for each sheet (e.g., Sheet1Data, Sheet2Data, Sheet3Data)

  • Each PageList contains the properties (columns) that will appear in the corresponding Excel sheet

  1. Populate PageLists via Data Transforms
  • Use Data Transforms (or an Activity) to query the Work Table

  • Map the relevant data into each PageList under the PageGroup:ExcelData(Sheet1).Sheet1Data(1).PropertyA = “Value”

    ExcelData(Sheet1).Sheet1Data(1).PropertyB = “Value”

  1. Configure the Excel Template
  • Create an Excel Template (.xlsx) with 3 separate sheets

  • In each sheet, reference the properties from the corresponding PageList directly using Pega template syntax: {.Sheet1Data().PropertyA input}

  • Each sheet is bound to its respective PageList so Pega iterates through the rows automatically

  1. Call pxGenerateExcelFile
  • In your Activity, call the OOTB pxGenerateExcelFile on the pagegroup
  • Pass the Excel Template as parameters
  • The activity iterates over the PageLists and populates each sheet accordingly
  1. Download / Attach the File
  • Stream the generated Excel file to the user for download or attach it to the case

Thanks for sharing. Couple of related links (Constellation):