cancel
Showing results for 
Search instead for 
Did you mean: 

getting error in spreadsheet download after deployment eventhough its working on webide

former_member592880
Participant
0 Kudos
2,387

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:

Accepted Solutions (1)

Accepted Solutions (1)

maheshpalavalli
Active Contributor

Hi Siddharth Shaligram

It seems that framework is unable to load the control and this control seems to available from 1.50 release. So make sure you system UI5 version is above 1.50 and check your code also once if it is written correctly.

https://ui5.sap.com/#/api/sap.ui.export.Spreadsheet/constructor

BR,

Mahesh

Answers (0)