on 2018 Nov 16 11:48 AM
I'm trying to export my table from fiori into an excel file. the export was working perfectly when on webide but gives error after deployment.
code:
createColumnConfig: function() {
return [{
label: "PO Number",
property: "EBELN"
}, {
label: "Created Date",
property: "AEDAT",
width: "25"
}, {
label: "1st Approver",
property: "NAME1",
width: "25"
}, {
label: "Approved On",
property: "DATE1",
width: "25"
}, {
label: "2nd Approver",
property: "NAME2",
width: "25"
}, {
label: "Approved On",
property: "DATE2",
width: "25"
}, {
label: "3rd Approver",
property: "NAME3",
width: "25"
}, {
label: "Approved On",
property: "DATE3",
width: "15"
}, {
label: "Net Aging Days",
property: "NTDAYS",
width: "15"
}];
},
download: function() {
var aCols, oSettings;
aCols = this.createColumnConfig();
var fromdate = this.getView().byId("fromDate")._lastValue;
var todate = this.getView().byId("toDate")._lastValue;
var arr1 = fromdate.split('/');
var fromDateValue = arr1[0] + "/" + arr1[1] + "/" + "20" + arr1[2];
var arr2 = todate.split('/');
var toDateValue = arr2[0] + "/" + arr2[1] + "/" + "20" + arr2[2];
var todt = new Date(toDateValue);
var fromdt = new Date(fromDateValue);
var year = todt.getFullYear();
var month = todt.getMonth() + 1;
var date1 = todt.getDate();
var hour = "00";
var min = "00";
var to = "datetime" + "'" + year + "-" + month + "-" + date1 + "T" + hour + ":" + min + "'";
var year1 = fromdt.getFullYear();
var month1 = fromdt.getMonth() + 1;
var date2 = fromdt.getDate();
var hour1 = "00";
var min1 = "00";
var from = "datetime" + "'" + year1 + "-" + month1 + "-" + date2 + "T" + hour1 + ":" + min1 + "'";
var sURI = "/sap/opu/odata/AAG362/MM_PO_ANALYSIS_01_SRV/";
//var oDataModel = new sap.ui.model.odata.ODataModel(sURI, false, "x362ben001", "Onama@123");
var oDataModel = new sap.ui.model.odata.ODataModel(sURI, false);
var oHeaders = {
'Accept': 'application/json',
"X-Requested-With": "XMLHttpRequest",
"Access-Control-Allow-Origin": "*"
};
var functionWithsFilter = "/AginglistSet?$filter=FROMDATE eq " + from + " and TODATE eq " + to;
// oDataModel.read("/AginglistSet?$filter=FROMDATE eq datetime'2018-09-01T00:00' and TODATE eq datetime'2018-10-10T00:00'", {
oDataModel.read(functionWithsFilter, {
header: oHeaders,
async: false,
//async: true,
success: function(oData, response) {
if (oData.results !== "undefined" || oData.results !== null) {
var resultData = oData.results;
oSettings = {
workbook: {
columns: aCols
},
dataSource: resultData
};
var oSpreadsheet = new sap.ui.export.Spreadsheet(oSettings);
oSpreadsheet.build()
// new Spreadsheet(oSettings)
// .build()
.then(function() {
MessageToast.show("Spreadsheet export has finished for Aging List Data");
});
}
},
error: function(error) {
MessageBox.show("Backend connection service data issue while downoading", {
icon: sap.m.MessageBox.Icon.ERROR,
title: "Error",
details: error
});
}
});
},
error:
Request clarification before answering.
I have answered the issue in the following:
I hope this works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
54 | |
6 | |
6 | |
5 | |
5 | |
5 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.