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 the charts using export to excel option



The user is unable to export the chart using "To Excel" option.

Error Messages

Not Applicable.

Steps to Reproduce

1. Create a report and add chart.
2. Also enable "Export to Excel".
3. Run the report and click on export to excel.

Result:The chart is not getting exported to excel.

Root Cause

This is expected behaviour. PRPC is designed to export only the data and not the chart from the report.


Following local-change uses third party tool PhantomJS to take the snapshot of chart in PDF only.
You must download PhantomJS locally on your system.

About PhantomJS

PHANTOMJS is a headless webkit scriptable with a JS API. It is used to take snapshots of the web URL’s.  In order to get report viewer chart into PDF you can use this phantomjs.
Steps involved:
  • A JS file is required to take the URL and crop the page accordingly. (Additionally it dumps the image at some physical location)          
  • An activity which actually calls the phantomjs webkit which internally calls the JS file. (This activity will wait for the phantomjs response and ones it is done it gets the chart image into the markup) 
 JS file(named chartURL.js)
// Passing hard coded user id and password and passing URL and chartName dynamically
var page = require('webpage').create();
page.viewportSize = { width: 2000, height: 3000 };
page.settings.userName = ""; //set username
page.settings.password = "";//set password
 page.settings.clearMemoryCaches = true;
 var reportURL = phantom.args[0];
 phantom.clearCookies();, function () {
 var waitNRun=function(){
   console.log("In wait");
 result= page.evaluate(function () {
var divs = document.getElementsByTagName('div');
var chartDiv;
for (var i = 0; i < divs.length; i++) {
    if (divs[i].getAttribute('id') != null && divs[i].getAttribute('id').indexOf('ichartDiv') == 0) {
        var reg = /^\d+$/;
        if (reg.test(divs[i].getAttribute('id').split('ichartDiv')[1])) {
            chartDiv = divs[i];
                else if (divs[i].getAttribute('id') != null && divs[i].getAttribute('id').indexOf('staticChart') == 0) {
        var reg = /^\d+$/;
        if (reg.test(divs[i].getAttribute('id').split('staticChart')[1])) {
            chartDiv = divs[i];
var  curtop=0,curleft = 0;
var chartDivForTop=chartDiv;
   if (chartDivForTop.offsetParent) {
        do {
            curtop += chartDivForTop.offsetTop;
                                                curleft += chartDivForTop.offsetLeft;
        } while (chartDivForTop = chartDivForTop.offsetParent);
return [chartDiv.offsetHeight,chartDiv.offsetWidth,curtop,curleft];
       console.log('Crop brand new to : '+result[0]+"x"+result[1]+"x"+result[2]+"x"+result[3]);
       page.clipRect = { top: result[2] +10, left: result[3], width: result[1], height: result[0] -45};
        window.setTimeout(function () {
            page.render('\\\\some_shared_location\\phantom\\Chart_Name.png'); //Give some physical location which is again needed in activity
        }, 20000);

 Activity Steps
 pyPDFSettings available rule is used to invoke phantom. (since it is available rule customers can make changes to it accordingly)
Set variables:
Using Property-Set method of an activity set phantomjs location as well as js file location into some local variables.

Call phantomjs:

Use a java step of an activity call phantomjs as described below:

Embed chart into PDF markup:



Published January 31, 2016 - 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