Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Export data from Visualization API straight table?

So far, I am able to dynamically build a straight table using the Visualization API.


Also, I can export a pre-existing table to a spreadsheet using the Table API.

The next step for our project is export the data from that dynamic table we just built.

This is where I hit a brick wall...

When pulling back a (pre-existing) visualization from our app, the visualization comes back with a qHyperCube object.

When I get back the visualization I just built -- using the Visualization API -- it does NOT come with the qHyperCube objet.

So qlik.table(visual).exportData(ops,callback) returns something like "Method exportData does not exist" for the new table.

That same code works as expected on the pre-existing objects I pull back from my app.

Has anyone had any success with exporting data from a dynamically created straight table?

Is it even possible?

Thanks!

7 Replies
s29124141
Partner - Creator II
Partner - Creator II

Hi Michael, where you able to export data from the objects created using visualization API? I am looking for similar solution.

satyaprakash
Partner - Contributor III
Partner - Contributor III

Hi ,

Did you found solution ?

Regards,

Satya

s29124141
Partner - Creator II
Partner - Creator II

You can use below code.

myApp.visualization.get($(chart).attr('data-qlik-objid')).then(function (visual) {

table = qlik.table(visual.model);

Export();

});

var Export = function () {

table.OnData.unbind(Export);

console.log(table);

table.exportData({ format: 'OOXML', download: false }, function (link) {

//Destroy table created in session.

app.destroySessionObject(table.model.id);

$('.preloader-wrap').fadeOut();

});

};

var ExportToCSV = function () {

table.OnData.unbind(ExportToCSV);

table.exportData({ format: 'CSV_C', download: false }, function (link) {

//Open CSV in new window.

var exportWindow = window.open('http' + (config.isSecure ? 's' : '') + '://' + config.host + ':' + config.port + link, '_blank');

try {

exportWindow.focus();

}

catch (e) {

}

//Destroy table created in session.

app.destroySessionObject(table.model.id);

});

};

Aiham_Azmeh
Employee
Employee

Hi,

The Qvisualization model returned from the `get` or `create` method from visualization API comes with a QTable model => https://help.qlik.com/en-US/sense-developer/June2018/Subsystems/APIs/Content/CapabilityAPIs/Visualiz...

... so you don't need to wrap it like this `table = qlik.table(visual.model);`

you can access it directly:

myApp.visualization.get([object_id]).then(visModel => {

   visModel.table.exportData({...});

})

this way you don't need to destroy the session Object - it will clean itself when you will close the visualization `visModel.close()`

/aiham

satyaprakash
Partner - Contributor III
Partner - Contributor III

Hi @Aiham,

I tried these steps, but qlik visualization table doesn't  have qMatrix data (though it contains hypercube structure).

Capture2.PNG

And after calling export function, qlik gives internal server error.

Capture.PNG

Do you have any solutions for it?

Regards,

Satya

Aiham_Azmeh
Employee
Employee

Hi Satya,

Table API uses "rows" for data:

app.visualization.get('uETyGUP').then(visModel=>{

  visModel.show('QV01');

  visModel.table.getMoreData();

  console.log('rows',visModel.table.rows)

  visModel.table.exportData({ format: 'CSV_C', download: true }, function (link) {

    console.log(link)

  });

})

Regarding the exportData function throwing an internal server error, I couldn't reproduce it - It looks like a bug, you should report it.

satyaprakash
Partner - Contributor III
Partner - Contributor III

Thanks Aiham,

This solution worked for SEP 2018 version. It was giving error for JUNE version.