Encode a .xlsx file into Base64
I am working in a user story which I need to convert a Page List into a .xlsx file. After that, I need to send this file as a Base64 string inside a connector.
I separated this user story in 3 steps:
- Call MSOGenerateExcelFile to generate the .xlsx file. - Done
- Use Base64Encode() function to convert the .xlsx into a Base64 string. - Doing
- Call the integration.
I did the first step successfully, but I don't know how to do the second step.
I saw in the bellow link that I can use this function to convert a Binary File into a Base64:
So, I was thinking to create a Binary File from the .xlsx that I have and call the Base64Encode() function to do this whole process, but I cannot figure out how to convert my file into a Binary File inside Pega.
Can someone give me hints to do that or maybe suggest another approach to create the Base64 string?
Witon S. Tuji.
I wanted to post a solution that I figured out:
After generating the .xlsx file with the MSOGenerateExcelFile, I did a property-set to the pxRequestor.pyFileUpload property. The set value is the pxProcess.pxServiceExportPath (Pega path) + the file name (declared in the MSOGenerateExcelFile).
To finish, I called the function @uploadFile() in a property-set which populated string type property. This property will contain your Base64, File Extension, File Name and File Path.
This @uploadFile() function will look at the file path located in pxRequestor.pyFileUpload, thats why I needed to populate this property after the MSOGenerateExcelFile.
Hope it helps someone in the future.
Keep up to date on this post and subscribe to comments