Export Data Page (list) to Excel

A step by step of exporting a Data Page list to an Excel file using Platform 8.8.2:

  1. Create a Data Page list.
  • This example uses a report definition as a source which queries sample data entered in the Data Type record.

  1. Create an Excel template file (see a sample attached)
  • Reference the data page name and pxResults() followed by a property name.
  • Notice that we can stye the Excel template file such as adding a color to the header. Column D is also set with ‘Wrap text’.

Note - it appears that the Excel template doesn’t take parameterized data page. One workaround is to use a Page-Copy step to copy from the data page [parameter] to a temporary activity page, which then can be used in the Excel template. E.g. {MySampleDataTypeListFiltered.pxResults().pxCreateDateTime}

  1. Upload the Excel template file as a binary file in Platform.

  1. Create an activity with one step - Call pxGenerateExcelFile
  • Parameter 1 = Excel output file name
  • Parameter 2 = Excel template name (“excel!SampleDataTypeDataPage!xlsx”)
  • Parameter 3 = Select DownloadFile checkbox

  1. (Unit test) Run the activity to generate and download the Excel output file.

Attach Excel file to email

If you have a requirement to send this Excel file as an email attachment, this article demonstrates how to configure it step by step.

sampledatatypedatapage (6).xlsx (10.1 KB)

@Will Cho How to handle parameterized data pages for excel functionality, let’s say based on the parameters for my list data page, the result count will vary.

@Will Cho How to create the xlsx file dinamically? How can user user have the choice of what property will show in the file?

@LuizFranciscoC If you are asking about changing Excel template dynamically, i haven’t done it before. This article is related to an Excel template pre-uploaded to Pega Platform in advance.

Regarding the property mapping, you can refer to this screenshot for a sample mapping. You will enter the property name directly inside {}.

51.png

@Will Cho, Thank you for the detailed explanation. Is it possible to refer to a page list inside a page list property?

Ex: TopLevelPage.PageListA().PageListB().Total

I tried to map the Total in the template, but it is not working on export. Any thoughts?

Thanks.

@Will Cho your solution works fine but when we are using “Export to Excel” from button click it needs below additional step, hope it helps to others

  • after adding action to call activity on button click next we need to add below action

Open URL in Window pass DownloadFile as OOTB activity

mention file name which we mentioned while exporting in the export activity ( here in this case ExcelOutputs.xlsx)

@Will Cho

Thanks, Will! I appreciate the detailed explanation, especially the workaround for parameterized data pages. This is exactly what I needed

@AkshithReddyT In Step 2 above, I’ve documented the following. Have you tried this? I think I’ve also faced an issue when using parameterized data page directly in the Excel template. But, when i first copied to a clipboard page (MySampleDataTypeListFiltered), which was then used in the Excel template, it worked fine.

Note - it appears that the Excel template doesn’t take parameterized data page. One workaround is to use a Page-Copy step to copy from the data page [parameter] to a temporary activity page, which then can be used in the Excel template. E.g. {MySampleDataTypeListFiltered.pxResults().pxCreateDateTime}

@KrushanthanR i tried a pagelist of pagelist structure and it didn’t generate an Excel file. If there is an embedded pagelist of another pagelist, that is like inserting a list inside each Excel cell which i haven’t seen in Excel. For now, i’m assuming that we can map only one level of pagelist to Excel.

@Will Cho Thank you so much for your reply. I tried it on my end, and as you said, it’s not recognized in the output file. Looks like I need to find a workaround for this. Once again, thank you for checking.