{
"items": [{
"firstName": "Navya",
"lastName": "Gowda",
"jobTitle": "Senior System Engineer",
"location": "India",
"department": "EASSAP"
}, {
"firstName": "John",
"lastName": "Smith",
"jobTitle": "Technology Architect",
"location": "USA",
"department": "EASSAP"
}, {
"firstName": "Emma",
"lastName": "Watson",
"jobTitle": "System Engineer",
"location": "Europe",
"department": "Testing"
}, {
"firstName": "Rahul",
"lastName": "Singh",
"jobTitle": "Manager",
"location": "India",
"department": "EASSAP"
}, {
"firstName": "Sinchi",
"lastName": "Kotaro",
"jobTitle": "System Engineer",
"location": "UK",
"department": "EASSAP"
}]
}
"sap.ui5": {
…………………………….
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "DownloadToExcel.i18n.i18n"
}
},
"Data": {
"Data": {
"type": "sap.ui.model.json.JSONModel",
"uri": "model/Data.json"
}
}
},
"resources": {
"css": [{
"uri": "css/style.css"
}]
}
}
<Button icon="sap-icon://download" text="Download" press="onDataExport" tooltip="{i18n>download}" id="download"/>
onInit: function() {
var oModel = new sap.ui.model.json.JSONModel("model/Data.json");
sap.ui.getCore().setModel(oModel, "oModel");
}
onDataExport: sap.m.Table.prototype.exportData || function() {
var oModel = sap.ui.getCore().getModel("oModel");
var oExport = new Export({
exportType: new ExportTypeCSV({
fileExtension: "csv",
separatorChar: ";"
}),
models: oModel,
rows: {
path: "/items"
},
columns: [{
name: "First Name",
template: {
content: "{firstName}"
}
}, {
name: "Last name",
template: {
content: "{lastName}"
}
}, {
name: "Job Title",
template: {
content: "{jobTitle}"
}
}, {
name: "Location",
template: {
content: "{location}"
}
}, {
name: "Department",
template: {
content: "{department}"
}
}]
});
console.log(oExport);
oExport.saveFile().catch(function(oError) {
}).then(function() {
oExport.destroy();
});
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
6 | |
6 | |
6 | |
6 | |
4 | |
4 | |
4 | |
4 | |
4 |