Skip to main content

Integration, Extension & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

cancel
Showing results for 
Search instead for 
Did you mean: 
xiaojunzai
Contributor III
Contributor III

How to export data on qliksense mashup

Hi all,pls tell me how to export data on qliksense mashup,can not be exported by clicking the right mouse button or with an extension without any restrictions,thank you!

11 Replies
jesper_snihs
Partner - Creator II
Partner - Creator II

Hi Junzai,

The code I will display is not the complete code but I will try to guide you through the example.

This is how I have solved it:

In the .js file I have the following function and this is being called everytime a user right-click on a container with the class "right-click-toolbar". Right-clicking on this container brings up a modal with some options. One of the option is the export data link:

$( ".right-click-toolbar" ).contextmenu(function(event) {

    event.preventDefault();

    var containerID = $(this).find("[data-qvobject]").attr('id');

   

    var qlikObjects = setObjects.toString();

    if(qlikObjects.indexOf(containerID) != -1){

        var tmpString = qlikObjects.substr(qlikObjects.indexOf(containerID), qlikObjects.length);

        var ptrn = /(\d+|\w+|-_)/g;

        var match, qlikID;

        var test = ptrn.exec(tmpString);

        if((match = ptrn.exec(tmpString)) != null){

            qlikID = match[0];

        }       

    }

    $( ".export-data-link" ).attr({

        'qvdata-id': qlikID

    });

});

So what we do here is to find the id of the container that has the QV-object and attach that ID to the export link.

Next part of the the .js-file handles when the user clicks the export button:

$( ".export-data-link" ).click(function(event) {

    event.preventDefault();

    var qlikID = $(this).attr("qvdata-id");

    exportObject(qlikID);

});

var exportObject = function(qvObj){

      app.getObject("export-container", qvObj).then(function(retObj){

          retObj.exportData( 'OOXML', '/qHyperCubeDef').then(function(c){

              var d = "../.." + c.qUrl;

              $('.exportChart').attr({

                  'filename': "download",

                'download': true,

                'href': d

            });

          });

      });

};

The HTML looks like this:

<div class="right-click-toolbar">

    <div id="QV01" class="qvobject" data-qvobject=""></div>

</div>

I have removed a lot of code so it might be so that this will not work as it is since I haven't tested it completely. Let me know if you have any issues.

rajeshshuklars
Contributor II
Contributor II

Hi Jesper_snihs,

 

I tried your solution however its not working. In the container where I am loading the qliksense table its not recognizing the right click context menu and I see regular chrome right click menu. Any though or elaborate steps would be helpful Thanks

ajaykakkar93
Specialist
Specialist

Hi,

Visit this link its Table Api will will be used.

in HTML:

<button id="buttonID">Export</button>

in JS :

var app = qlik.openApp('Automotive.qvf', config);

//get objects -- inserted here --
app.getObject('QV01','utuwT').then(function(reply){
$('#buttonID').click(function(){
var qTable = qlik.table(reply);
qTable.exportData({download: true});
});
});

ajaykakkar93
Specialist
Specialist

hi,

Here is the example with Table Api 

rajeshshuklars
Contributor II
Contributor II

Thanks Ajay, I will take a look and get back to you.

pprakriya
Contributor II
Contributor II

Ajay,

I tried to use this example to export to excel and having trouble not able to see Export button in View in dev hub.

Any ideas on what i am missing?

Appreciate your help.

Thank you,

Padma 

 

 

ajaykakkar93
Specialist
Specialist

Check if you have Automotive.qvf
have you altered the code if yes then re download & check if you could share a image it will be helpful

Harsh_Gohil
Partner - Contributor III
Partner - Contributor III

hello,

 

try this 

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config); app.visualization.get('xGhjKl').then(function(vis){ vis.exportData({format:'CSV_T', state: 'A'}).then(function (link) { window.open(link); }); });