Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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.
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
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});
});
});
Thanks Ajay, I will take a look and get back to you.
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
hello,
try this out if it will help
Thanks Regards,
Harsh Gohil
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); }); });