Support Article
Unable to export Excel file using MSOGenerateExcelFile activity
Summary
Unable to export an Excel file using MSOGenerateExcelFile activity.
Error Messages
Not Applicable
Steps to Reproduce
- Load an input 'xlsx' template in to the directory as a binary file (for example, excel/template.xlsx).
- Create a section with a repeat grid and add a button in the grid.
- Configure button actions with 'Refresh this Section' action.
- Provide input parameters to invoke the MSOGenerateExcelFile activity.
Root Cause
Invoking the 'Refresh this Section' action with MSOGenerateExcelFile activity is an invalid configuration because the response for the action should be of type HTML to render the section. However, the response to be downloaded was of MIME type.
Resolution
Perform the following local-change:
- Create a wrapper activity (for example, TEMPExportExcel) and call the MSOGenerateExcelFile activity.
- Copy the following JavaScript function to the UserWorkForm.
function downloadMSExcel(fsFileName, templateRFB, downloadFile ){
var form = document.createElement('form');
form.id = "formExportViewToExcel";
form.method = "POST";
form.target = "_target";
document.body.appendChild(form);
var frm = document.forms["formExportViewToExcel"];
var strUrlSF = SafeURL_createFromURL(pega.u.d.url);
strUrlSF.put("pyActivity", "TEMPExportExcel");
strUrlSF.put("FSFileName", fsFileName);
strUrlSF.put("TemplateRFB", templateRFB);
strUrlSF.put("DownloadFile", downloadFile);
frm.action = strUrlSF.toURL();
frm.submit();
document.body.removeChild(form);
}
</script>
3. Call the 'downloadMSExcel' custom function from the button click with 'Run Script' action.
Published July 25, 2018 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.