on 05-13-2017 8:01 AM
Hello Folks ,
I am using below code to download data into excel . Data is getting downloaded into excel but all the rows are getting downloaded on same line
var table = this.getView().byId( "SesListtable"); var oModel = this.getView() .getModel(); var cols = table.getColumns(); var items = table.getItems(); var cellId = null; var cellObj = null; var cellVal = null; var headerColId = null; var headerColObj = null; var headerColVal = null; var column = null; var json = {}; var colArray = []; var itemsArray = []; // push header column names to array for (var j = 0; j < cols.length; j++) { column = ""; column = cols[j]; headerColId = column .getAggregation( "header") .getId(); headerColObj = sap.ui.getCore() .byId(headerColId); headerColVal = headerColObj .getText(); if (headerColObj.getVisible()) { json = { name : headerColVal }; colArray.push(json); } } itemsArray.push(colArray); // push table cell values to array for (var i = 0; i < items.length; i++) { colArray = []; cellId = ""; cellObj = ""; cellVal = ""; headerColId = null; headerColObj = null; headerColVal = null; var item = items[i]; for (var j = 0; j < cols.length; j++) { cellId = item .getAggregation("cells")[j] .getId(); cellObj = sap.ui.getCore() .byId(cellId); if (cellObj.getVisible()) { if (cellObj instanceof sap.m.Text || cellObj instanceof sap.m.Label || cellObj instanceof sap.m.Link) cellVal = cellObj .getText(); if (cellObj instanceof sap.m.ObjectNumber) { var k = cellObj .getUnit(); cellVal = cellObj .getNumber() + "" + k; } if (cellObj instanceof sap.m.ObjectIdentifier) { var objectIdentifierVal = ""; if (cellObj .getTitle() != undefined && cellObj .getTitle() != "" && cellObj .getTitle() != null) objectIdentifierVal = cellObj .getTitle(); if (cellObj .getText() != undefined && cellObj .getText() != "" && cellObj .getText() != null) objectIdentifierVal = objectIdentifierVal + "" + cellObj .getText(); cellVal = objectIdentifierVal; } if (cellObj instanceof sap.ui.core.Icon) { if (cellObj .getTooltip() != undefined && cellObj .getTooltip() != "" && cellObj .getTooltip() != null) cellVal = cellObj .getTooltip(); } if (j == 0) { json = { name : "\r" + cellVal }; } else { json = { name : cellVal }; } colArray.push(json); } } itemsArray.push(colArray); } // export json array to csv file 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 : oModel, // binding information for the rows aggregation rows : { path : table.getBinding("items").getPath(), }, // column definitions with column name and binding // info for the content columns : [ itemsArray ] }); oExport.saveFile().always( function() { this.destroy(); });
Can anyone please help me resolve issue asap?
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.