问题
Below is my code for download to xls feature. I am not sure why its not woking in Edge. However , it works fine in chrome. There are no console errors too. Not sure which part of the below of line of code is not supported in Edge. Is there any other way to rewrite the below code so that it supports edge.
$scope.downloadXls = function() {
var repayments = $scope.repayments;
var csvContent = "data:text/csv;charset=utf-8,";
var rows = [
[
"Payment No",
"Installment",
"Principal",
"Interest",
"Balance",
]
];
for (var i = 0; i < repayments.length; i++) {
rows.push([
i + 1,
parseFloat(repayments[i].installment).toFixed(2),
parseFloat(repayments[i].principal).toFixed(2),
parseFloat(repayments[i].interest).toFixed(2),
parseFloat(repayments[i].balance).toFixed(2)
]);
}
rows.forEach(function(rowArray) {
let row = rowArray.join(",");
csvContent += row + "\r\n";
});
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "repayment_schedule.csv");
document.body.appendChild(link); // Required for FF
link.click();
}
来源:https://stackoverflow.com/questions/59177227/why-download-to-xls-feature-doesnt-work-in-edge-browser-but-works-in-chrome