function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Larry WeiburgLarry Weiburg 

Lightning Component: CSV Download on Microsoft Edge

Hello everyone,

I'm trying to generate a CSV through a lightning component and allow the User to download it upon the click of a lightning button. This component is on a lightning community page. The onclick calls the following.
let csvName = 'downloadTest';
if (navigator.msSaveBlob) {
    var blob = new Blob([content], { type: 'text/csv;charset=utf-8;' });
    navigator.msSaveBlob(blob, csvName);
} else {
    let anchorLink = document.createElement('a');
    anchorLink.href = 'data:text/csv;charset=utf-8,' + encodeURI(content);
    anchorLink.target = '_self';
    anchorLink.download = csvName + '.csv';
    document.body.appendChild(anchorLink);
    anchorLink.click();
}


It works on Chrome and Firefox, but on Microsoft Edge it always shows "...couldn't be downloaded", and there are no other options aside from cancel. Would anyone happen to know how to get around this?
Best Answer chosen by Larry Weiburg
VinayVinay (Salesforce Developers) 
Hi Larry,

Unfortunately, there is no workaround and as per the documentation, it clearly says to use other supported browsers for enhanced security.  IE11 is one of the few browsers that do not implement required security standards.

Reference:
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/security_ls_unsupported.htm

Thanks,
Vinay Kumar

All Answers

VinayVinay (Salesforce Developers) 
Hi Larry,

I believe this is due to locker service.

As per below document,  IE11 doesn’t support CSP, so we recommend using other supported browsers for enhanced security.

Review below link for more information.

https://developer.salesforce.com/blogs/developer-relations/2016/04/introducing-lockerservice-lightning-components.html

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
Larry WeiburgLarry Weiburg
Hi Vinay,

Does that mean nothing can be done to work around this issue on Microsoft Edge? And the course of action would just be to recommend end users to use a different browser?
VinayVinay (Salesforce Developers) 
Hi Larry,

Unfortunately, there is no workaround and as per the documentation, it clearly says to use other supported browsers for enhanced security.  IE11 is one of the few browsers that do not implement required security standards.

Reference:
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/security_ls_unsupported.htm

Thanks,
Vinay Kumar
This was selected as the best answer
Larry WeiburgLarry Weiburg
Okay, while that's unfortunate I'm thankful for the answer because I've been looking for and trying out workarounds for the past few days.
VinayVinay (Salesforce Developers) 
Cheers....!! Have a Good one.