Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
10dulkar
Contributor II
Contributor II

Unable to export to excel in Qlik Sense mashups.

Hi All,

I have my Qlik Sense report converted into a mashup which is deployed to QAP set up.

I need to have my charts & tables exported to excel for which I have tried the below jQuery code :

require( ["js/qlik", "jquery"], function ( qlik, $ ) { 

   qlik.setOnError( function ( error ) { 

      alert( error.message ); 

   } ); 

 

  var app = qlik.openApp('d5d74472-04f9-4add-9002-7925e504ab2c', config); 

 

  app.getObject('QV01','WTjpK').then( function( vizModel ) { 

 

      // Prevent clicking on the button too early 

      //$('#cmdExport').show(); 

 

 

      $('#cmdExport').on('click', function() { 

 
 
         vizModel.exportData().then(function( reply ) { 
  
  
            console.log('qUrl', reply); 
  
            window.open(reply.result.qUrl); 

         }); 

      }); 

   }); 

}); 

  However, I am getting the below error :

Unable to get property 'qUrl' of undefined or null reference.

Any help would be much appreciated.

4 Replies
Aiham_Azmeh
Employee
Employee

Hi 10dulkar‌,

The model reurned from `QApp.getObject` - is not supported. The way you can do exportData with the capability APIs is by using Table API => https://help.qlik.com/en-US/sense-developer/June2018/Subsystems/APIs/Content/CapabilityAPIs/TableAPI...

The table model is also exposed in Visualization API so should be able to do:

var app = qlik.openApp('d5d74472-04f9-4add-9002-7925e504ab2c', config);

  app.visualization.get('WTjpK').then( function( vizModel ) {

      visModel.show('QV01');

      // Prevent clicking on the button too early

      //$('#cmdExport').show();

      $('#cmdExport').on('click', function() {  

         vizModel.table.exportData().then(function( reply ) {    

            console.log('qUrl', reply);   

            window.open(reply.result.qUrl);

         });

      });

   });

I hope this helps

10dulkar
Contributor II
Contributor II
Author

Hi Aiham,

This definitely helps! Thanks a lot!! But I still need help in 2 things :

1) Getting the below pop-ups while browsing the mashup, once we click on the "OK" button, everything works fine.

How do I get rid of these pop-ups? 

2) Export to excel happens but the dump gets exported to the "tempcontent" folder on my QS Server.

If we were to publish the mashup & the end user were to view the mashup through a URL; will the export still work? Where will the export dump get stored then?

Please help me with the above questions.

Aiham_Azmeh
Employee
Employee

Hi Mahesh, (sorry for late reply)

1) this shouldn't happen - it looks like you are trying to open an app that doesn't exists - or have no access rights to it? I don't know for sure

2) assuming that the user is authenticated correctly, yes - you may probably need to build the URL since the mashup is deployed elsewhere, something like:

vizModel.table.exportData().then(function( reply ) {      

            console.log('qUrl', reply);     

            window.open('https://[your-qlik-server]/'+reply.result.qUrl);

I hoe this helps

10dulkar
Contributor II
Contributor II
Author

Thanks Aiham! This was very helpful & I was able to sort the issue out...