Upload an Excel file, Parse it and Display the Content.

This is a simple POC, how we can upload an Excel file into Pega and then parse it and display the results in a tabular format in a section.

Demo Video:

Lets start !!!

Login to Pega PE 8.5.1

  1. Create a Data table to get the Page with property
  2. Create a case type
  3. Create a binary file for the Excel file to upload
  4. Create an activity to parse the excel
  5. Create a section to display the data

Data type with 3 columns (Col1, Col2, Col3)

Create a case type

Take a text input – then change it to FilePath

Go to other and then type FilePath– you will get the control

SetEncodingNow – checked

pySetValueFromFileName – pyFilePath

Create a binary file rule

Upload File

TemplateFile.xlsx

Save the binary rule.

Now lets create the activity to fetch the Excel file — As of now we have uploaded the binary file that is we told the system what kind of file I will upload.

Now lets write the activity

FileContent is the new page to hold the data

Param.FilePath = pxRequestor.pyFileUpload — in the clipborad we can see that when we upload a file with FilePath control the the FilePath is saved in that path.

In step 3  use the step page as FileContent to hold the data–in clipboard will see the data in that page.

TemplateRFB = webwb!TemplateFile!xlsx

We need to show the data on a screen. So we have to send the data from FileContent page (This is a local page created as part of this activity) to a pagelist. FileContentList.

FileContentList pagelist should be of the same data class of FileContent.

MYOrg-IND-MySampleApp-Data-ExcelFileData

For using in utility shape we should make the activity as utility

Without using the utility shape we can call the activity in the postprocessing of the flowaction.

Now lets see the flow again,

After the utility we have the Show Data screen.

So lets design the section

In Table 1.1 call FileContentList — which is full of data as per the activity.

Now update the columns

Label

Now add the value .Col1 in the Data Type ExcelFileData

In presentation tab make it editable

If we select editable then after the data is available on the screen then user can edit it.

Check the Data Type columns — Col1, Col2, Col3

Now let’s Test it…..

Save and Run

Upload the excel file containing the data.

Hope you liked the article. It is quite simple and I hope you can clearly explain these steps in the next interview. Please try by yourself and then you will get more confidence.

Please do let me know your inputs in the comment box.

2 Comments

  1. The email listener creates a case in pega instance by picking up the body of the email. If a particular email contains an attachment with some properties, how do we create an email listener and also check the properties are extracted from the attachment?

    • When there are attachments in the email Pega puts all those attachments on page named “pyAttachmentPage”.Please refer to createworkfrommail activity and if required customize it accordingly.