Json To Csv / Xls Does Not Save A File On Ie
I have the following service: angular.module('LBTable').service('exportTable', function () { function JSONToCSVConvertor(JSONData, ReportTitle, ShowLabel, fileName) { /
Solution 1:
the Reason is IE doesn't support the download attribute in a tag. The work around is you can Use blob
getInternetExplorerVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
var re = newRegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat(RegExp.$1);
}
elseif (navigator.appName == 'Netscape') {
var ua = navigator.userAgent;
var re = newRegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat(RegExp.$1);
}
return rv;
}
- if the browser is IE
var blob = new Blob([CSV], { type: "text/csv;charset=utf-8;" });
navigator.msSaveBlob(blob, fileName + ".csv")
This will work in IE
Post a Comment for "Json To Csv / Xls Does Not Save A File On Ie"