Friday, January 3, 2020

Creating Excel Sheet with HTML Tags and sending as Email attachment

Creating Excel sheet with HTML Tags and Sending as Email attachment

In Pega PRPC, creating Excel sheet can be done in below ways:
1)By POI jar, using custom java code to create the Excel files with any custom record.
2)Using MSOGenerateExcel activity, which will use template excel to generate the properties to map and generate Excel
3)Using Just HTML table tags to create Excel file - we will see about this in this post.

Steps to follow:
1) Create an AttachmentPage and set the decode flags.




2) Call RDB List with SQL Query to generate the Page list which are to be exported to excel.

3) In a Parameter Flag, create a header tags in HTML table.
Param.XmlValue = "<HTML><BODY><TABLE border='1'><tr><td>Property1</td><td>property2</td>
<td>property3</td><td>property4</td></tr>"

4) Looping on the result which we got in Step 2 and set the values in tr td tags.
Param.XmlValue = Param.XmlValue + "<tr><td>""+.Property1+"</td><td>"+.property2+
"</td><td>"+.property3+"</td><td>"+.property4+"</td></tr>"


5) In Property set, Param.XmlValue = Param.XmlValue + "</table></body></html>"


6) attachment page, pyData string with @Base64Encode(Param.XmlValue)


7) Send Email Notification: - get the email account details and set some message in the mail if needed in the correspondence rule and set the resulted value to Param.Message.