on 2015 Nov 18 12:18 PM
Hi,
I searched the many forums but there is no use of me
I did the download .csv format but I need to download .xls format only
can you any once please help me on this...
I did for CSV:
onClick: function() {
var json = <jsondata>
var csv = this.JSON2CSV(json);
var fileName = "<filename>";
var uri = 'data:text/csv;charset=utf-8,' + escape(csv);
var link = document.createElement("a");
link.href = uri;
link.style = "visibility:hidden";
link.download = fileName + ".csv";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
JSON2CSV: function(objArray) {
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
var str = '';
var line = '';
var head = array[0];
if ($("#quote").is(':checked')) {
for (var index in array[0]) {
var value = index + "";
line += '"' + value.replace(/"/g, '""') + '",';
}
} else {
for (var index in array[0]) {
line += index + ',';
}
}
line = line.slice(0, -1);
str += line + '\r\n';
for (var i = 0; i < array.length; i++) {
var line = '';
if ($("#quote").is(':checked')) {
for (var index in array[i]) {
var value = array[i][index] + "";
line += '"' + value.replace(/"/g, '""') + '",';
}
} else {
for (var index in array[i]) {
line += array[i][index] + ',';
}
}
line = line.slice(0, -1);
str += line + '\r\n';
}
return str;
},
Request clarification before answering.
If you are getting your data from an OData service from Gateway, you could use $format=xlsx in the resource URI.
i.e. https://myhost.example.com/sap/opu/odata/sap/service/UserSet?$select=...&$filter=...&$format=$xlsx
This will get Gateway to output the data as an Excel file and is what the new Smart Template controls use.
Oli
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
21 | |
8 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.