Can GenerateExcel use a Base64/Binary template instead of Rule-File-Binary?

Hi everyone,

I’m using GenerateExcel with:

generator.generateExcelFromClipboardPage(tools.getParamValue(“TemplateRFB”), true);

This works when TemplateRFB contains a Rule-File-Binary reference (e.g. excel!MyTemplate!xlsx).

In my case, the template is stored dynamically as Base64/binary content instead of a Rule-File-Binary.

Does GenerateExcel support generating from Base64/binary templates directly, or does it only work with Rule-File-Binary references?

Thanks!

Hello @BharathSuntigikarHCL, Welcome to the Forums :slight_smile:

Yes, this is achievable in Java.

You can embed a predefined Excel template as a Base64-encoded string and use Apache POI to decode the template, populate it with dynamic data, and generate the final Excel file.

This approach allows you to preserve the template’s existing formatting, styles, formulas, merged cells, and worksheet structure while populating it with application data.

In Pega, this can be implemented through a java step in an Activity or even better to write the same java code embedded in a function with necessary parameters for reusability purpose, depending on your application requirements. The generated Excel file can then be returned as a downloadable file or attached to a case.

However, if the Excel template contains only the column headers and basic structure, does not contain any CID/PII information, and is not expected to change frequently, a simpler approach would be to maintain the template as a binary file in the application. This would eliminate the need to embed the template as a Base64 string and avoid the additional Java code required for decoding and managing it.

If the template changes frequently, the corresponding case data fields and their mappings to Excel would also need to be updated frequently. This would introduce ongoing maintenance of the template, Base64 content, and Java mapping logic.

Therefore, unless there is a specific requirement for a highly customized Excel output, it may be worth evaluating whether the standard Pega export capabilities can meet the requirement with less custom code and ongoing maintenance.

Hope this helps

Regards

JC