Qlik sense mashup export data to excel

Qlik-sense-mashup-export-data-to-excel

This blog explains one of the approaches to enable Qlik sense mashup export data to excel option for all the charts that will be loaded. If you want to export the visualization as an image from a mashup please refer to blog: Qlik sense screenshot extension update – for mashups

This approach makes use of the ExportData option of the capability API – Table API .

Approach to enable qlik sense mashup export data to excel

  • Link object id to DIV

Ensure the objectid of the charts loaded are linked to the DOM object in which the object will be loaded.

$("#"+divid).attr("export-id",objectid);

  • Bind mouse events to the div

Bind each div with two mouse events mouseenter and mouseleave in  order to add/ remove an Export button

MouseEnter

$("#"+divid).on("mouseenter",function(e){
$(this).append("&lt;button id='"+ divid+objectid + "' class='export_data'&gt;Export&lt;/button&gt;")</p>
<p style="padding-left: 30px;"></p>
<p style="padding-left: 30px;">.</p>
<p style="padding-left: 30px;">})

Mouseleave

$("#"+divid).on("mouseleave",function(e){
$('#' + divid + ' .export_data').remove();
})

 

  • Bind a click event to the Export button

Bind a click event to the export button so that click event retrieves the object id from the export-id attribute to fetch the object once more and use Table API to download the data. The options for export is given in Table API exportData function documentation

$('#'+divid+objectid).click(function(model){
app.getObject(objectid).then(function(model){
var d = app.table(model);
d.exportData({'format':'CSV_C','state':'A','filename': 'exportdata.csv','download': true})</p>
<p style="padding-left: 30px;">})</p>
<p style="padding-left: 30px;">})

Source Code: 

Working example with Executive Dashboard that comes along with Qlik sense installation is available. Please Use the below link to download the same.

Download Qlik Sense Mashup Export Data Example

1 Comment

  1. Hi,

    I’m trying this out, just did a copy/paste of the codes in my mashup.
    I’m getting an access denied error each time a I click on the export button.

    I’m running the mashup in QAP by the way.

    Any idea why?

Leave a Reply

Your email address will not be published.


*