I am able to export table data to excel dynamically, but some of the data like long numbers and negative values are formatted
Below is the UI Table data [enter image description here][1]
exported data to CSV [enter image description here][2]
when I select the long values it showing the proper value on top of excel, and -ve values are appended with '......
Code :
jQuery.sap.require("sap.ui.core.util.Export");
jQuery.sap.require("sap.ui.core.util.ExportTypeCSV");
sap.ui.define([
'jquery.sap.global',
'sap/ui/core/mvc/Controller',
'sap/ui/model/json/JSONModel'
], function(jQuery, Controller, JSONModel) {
"use strict";
var vSrcMATNR;
var oEvtBus = sap.ui.getCore().getEventBus();
var TableController = Controller.extend("UtilLoad.Util", {
exportToExcel: function(oTable) {
var that = this;
var aColumns = oTable.getColumns();
var aItems = oTable.getItems();
var aTemplate = [];
for (var i = 0; i < aColumns.length; i++) {
var oColumn = {
name: aColumns[i].getHeader().getText(),
template: {
content: {
path: null
}
}
};
if (aItems.length > 0) {
oColumn.template.content.path = aItems[0].getCells()[i].getBinding("text").getPath();
}
aTemplate.push(oColumn);
}
var oExport = new sap.ui.core.util.Export({
// Type that will be used to generate the content. Own ExportType’s can be created to support other formats
exportType: new sap.ui.core.util.ExportTypeCSV({
separatorChar : ",",
charset : "utf-8"
}),
// Pass in the model created above
models: oTable.getModel(),
// binding information for the rows aggregation
rows: {
path: "/"
},
// column definitions with column name and binding info for the content
columns: aTemplate
});
oExport.saveFile().always(function() {
this.destroy();
});
},
fnDate: function(sDate) {
if (sDate) {
var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({
pattern: "dd-MM-yyyy"
});
return oDateFormat.format(new Date(sDate));
} else {
return sDate;
}
}
});
return TableController;
});
from SAP documentation advicing to use data export functionality , please what is it and how
https://openui5.hana.ondemand.com/#docs/api/symbols/sap.ui.core.util.ExportTypeCSV.html
Thanks Rajesh