Hi, I have never tried on ionic. But with javascript you can do it with Blob :
var data = new Blob([text], {type: ‘text/csv’});
// If we are replacing a previously generated file we need to
// manually revoke the object URL to avoid memory leaks.
if (textFile !== null) {
window.URL.revokeObjectURL(textFile);
}
textFile = window.URL.createObjectURL(data);
var link = document.createElement(“a”);
link.setAttribute(“href”, textFile);
link.setAttribute(“download”, “csv.csv”);
And for the “text”, for each line you can do line + " \n "
var ConvertToCSV = function(objArray) {
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
var str = '';
for (var i = 0; i < array.length; i++) {
var line = '';
for (var index in array[i]) {
if (line != '') line += ','
line += array[i][index];
}
str += line + '\r\n';
}
return str;
};
This is working fine. I don’t need to download the file anymore…
The users will manage to send their own export to their email…
Can you please explain this? Whether first should call “ConvertToCSV” & then call “onSelectExport” ? what is the input for “ConvertToCSV” , where have you used the return value of it?