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
- 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
- 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”
- 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
- 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
- Download / Attach the File
- Stream the generated Excel file to the user for download or attach it to the case