You need to sign in to do that
Don't have an account?
Larry 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.
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?
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?
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
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
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?
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