Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I want to extract the data from an existing Visual from an existing Qlik App & store the result on Disk with a specific name.
I manage to do 1-3, but dont manage to change the filename of the downloaded file. Any advice?
//open app
var app = qlik.openApp('a5a8c513-d2e5-4ec9-be1e-1ebd995a493a', config);
// Get visuals data & export
app.visualization.get('EaqBxc').then(function(vis){
vis.exportData({format:'CSV_T', state: 'A'}).then(function (link) {window.open(link);
window.close();
});
});
} );
Thanks in advance
I will answer this one myself 🙂 you can rename the file in Client Javascript, however, its not possible to change the path. The file will always end up in your profiles Download folder set in your browser, which makes perfect sense.
If you want to specify filepath/name I assume Node.js is the way to go.
Hi @pauljohansson , your goal is to change the file name that it comes automatically from Qlik server, such as a50e4226-79e3-45cb-aed4-744dbd52c4b0.xlsx for an excel file?
If so, you can rename the exported file before giving it to the client. You can do it with few Javascript lines
Hej @alex_colombo ,
no , the goal is actually to change the download path, which is not possibly using client javascript - the file will always end up in the download folder. I guess the solution would be to go for Node.js,
br
Paul
Why do you want to change the download folder? This is a client setting which comes from browser settings. Or you mean the download url such as https://_qlikServer_/tempcontent/c4375340-0f60-4f8d-b42c-edb10f98db73/898f86e9-5700-4dee-a547-56ca04529cc2.xlsx?serverNodeId=f547ea7c-864a-44a3-87a2-00817848d756?
Hi @alex_colombo We are trying to export excel and pdf with a Qlik SaaS application. We are not able to rename the table download. We have given a title to the table and we want to use the title for the downloadable excel and pdf. Do you have code ready which we can reuse?
Default Export name for excel is : chart_excel.xlsx
Default Export name for PDF is: download.pdf
@RajDubey are you using Reports REST APIs? In any case, there is no way so set the exported file name with APIs call. You have to rename the file in your code before return it to the client.
Hi @alex_colombo and @pauljohansson,
We had been working on renaming the files from a50e4226-79e3-45cb-aed4-744dbd52c4b0.xlsx this format to Qlik_ChartName_Date.xlsx. Could you please help in providing the JavaScript code for it?
Below is the code we are using to export the files to excel.
$("className").click(function () {
app.getObject($("#" + $(this).attr("for")).data("qvid")).then(function (reply) {
var qTable = qlik.table(reply);
qTable.exportData({
download: true
});
});
})
Hey @RajDubey , if you are using SaaS I reccomend to use Reports APIs. exportData method is no supported on SaaS.
This is a simple example for creating a link tag and set a custom name to file.
//Download report
const report = await fetch(reportDownloadLocation, {
credentials: "include",
headers: {
"Qlik-Web-Integration-Id": webIntegrationId
}
});
const reportBlob = await report.blob()
const reportURL = URL.createObjectURL(reportBlob)
const link = document.createElement('a')
link.href = reportURL
//Rename exported files with a custom name before give it to client
link.setAttribute("download", `custom_report_name`);
document.body.appendChild(link)
link.click()
document.body.removeChild(link)