I'd like to download the table as an Excel file. But when the function is triggered, it always downloads as "data.csv" by default. I want a different name for the file. So how can I change the name of the downloaded file into something else?
{ // Snippet from my controller
toExcel: function () {
var oExport = new Export({
exportType: new ExportTypeCSV({ // required from "sap/ui/core/util/ExportTypeCSV"
separatorChar: ",",
charset: "utf-8"
}),
models: this.getView().getModel("oListOrderMod_rent"),
rows: { path: "/" },
columns: [
{
name: "Tenant Name",
template: {
content: "{tentName}"
}
},
{
name: "Address",
template: {
content: "{h_address}"
}
},
// ...
]
});
oExport.saveFile().catch(function(oError) {
MessageBox.error("Error when downloading data. ..." + oError);
}).then(function() {
oExport.destroy();
});
},
}
Clicking that button downloads the file. I want it to say something other than "data.csv"
Solution is quite obvious if you take a look into the API description:
The method saveFile
has a parameter which is the filename.
So just pass that parameter.
oExport.saveFile("myNewFileName.csv")
.catch(function (oError) {
// ...
})
.then(function () {
// ...
});