on 01-18-2019 8:14 PM
I am trying to download JSON data to an excel. It works fine except when I am running a for loop and trying to download the array in chunks of 25, it always duplicates the last file. More specifically, if there is only one record in the array, still 2 files get created.
Below is my code:
var i, j, temparray, chunk = 25, fileNumber;
var fileName = "Order export-";
for (i = 0, j = oModel.length, fileNumber = 1; i < j; i += chunk, fileNumber++) {
temparray = oModel.slice(i, i + chunk);
oSettings = {
workbook: {
columns: aCols
},
dataSource: temparray,
fileName: fileName.concat(fileNumber)
};
var oSpreadsheet = new sap.ui.export.Spreadsheet(oSettings);
oSpreadsheet.build().then(function () {
sap.m.MessageToast.show("Spreadsheet export has finished");
});
It sounds like you have a issue with a pointer to the RAM. You are not creating any copy of the data. Only pointers. This is why it is using the last one. It is the last to create the pointer. You can solve this with extending your data if i am correct. please try something like this
//create a "copy" of a object
var temparray = $.extend(true, {}, oModel.slice(i,i+ chunk));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for feedback. I tried doing that but I get the below error:
Uncaught TypeError: Cannot read property 'match' of undefined
at Object.l [as parse] (sapui5.hana.ondemand.com/1.52.4/resources/sap/ui/export/js/libs/uri.all.min.js:2)
at r (sapui5.hana.ondemand.com/1.52.4/resources/sap/ui/export/js/XLSXExportUtils.js:1)
at Object.c [as fetch] (sapui5.hana.ondemand.com/1.52.4/resources/sap/ui/export/js/XLSXExportUtils.js:1)
at onmessage (sapui5.hana.ondemand.com/1.52.4/resources/sap/ui/export/js/SpreadsheetWorker.js:1)
The file does not print for every loop. It prints everything at the end. I think that's somewhere the issue is.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.