Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Unable to export Excel file using MSOGenerateExcelFile activity

SA-61058

Summary



Unable to export an Excel file using MSOGenerateExcelFile activity.


Error Messages



Not Applicable


Steps to Reproduce

  1. Load an input 'xlsx' template in to the directory as a binary file (for example, excel/template.xlsx).
  2. Create a section with a repeat grid and add a button in the grid.
  3. Configure button actions with 'Refresh this Section' action.
  4. 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:
  1. Create a wrapper activity (for example, TEMPExportExcel) and call the MSOGenerateExcelFile activity.
  2. Copy the following JavaScript function to the UserWorkForm.
       <script>

       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

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us