Recently, I built an application using NDWS with sapui5 _javascript. Within the application, there is a table that contains data synced with the server's database. My goal is to retrieve this data from the table and export it to an Excel document. Here is the code snippet for triggering this action:
var oExportToExcelButton = new sap.ui.commons.Button( {
text : "Export to Excel",
width : '120px',
style : sap.ui.commons.ButtonStyle.Emph,
press : function() {
var jsonDataObject = oController.model.getProperty("/matreqs");
var taskIdFromView = sap.ui.getCore().byId("taskId").getValue();
var jsonData = JSON.stringify(jsonDataObject);
$.ajax("api/wpi/processrequest/getexcelexportfile?taskId="
+ taskIdFromView, {
context : this,
type : "POST",
processData : false,
contentType : "application/json",
data : jsonData,
error : function(request, status, error) {
console.log(error);
},
success : function(data) {
oController.getRequestParameterValue();
console.log(data);
top.close();
}
});
}
});
The getRequestParameterValue() function resides in the controller:
getRequestParameterValue: function(name) {
var half = location.search.split("&" + name + "=")[1];
if (!half) half = location.search.split("?" + name + "=")[1];
return half ? decodeURIComponent(half.split("&")[0]) : null;
})
I am fairly new to programming, so I apologize if my explanation is not very clear. Any assistance or guidance would be greatly appreciated!