You need to sign in to do that
Don't have an account?
srinath vallab
Download as csv in inline Visualforce page/Lightning component
Hi Salesforce Developers,
I have an inline Visualforce page on account detail page. And there is lightning component inside this VF page. There is some table of data and a "Download" button to download the given table as csv/excel. On button click, I tried to create CSV file using below code.
Any help would be much appreciated.
I have an inline Visualforce page on account detail page. And there is lightning component inside this VF page. There is some table of data and a "Download" button to download the given table as csv/excel. On button click, I tried to create CSV file using below code.
var hiddenElement = document.createElement('a'); hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv); hiddenElement.target = '_self'; // hiddenElement.download = 'ExportData.csv'; // CSV file Name* you can change it.[only name not .csv] document.body.appendChild(hiddenElement); // Required for FireFox browser hiddenElement.click(); // using click() js function to download csv fileThis is working in classic but not in Lightning. Below error is shown in lightning.
Any help would be much appreciated.
May I request you please refer the below link for reference Download Data as CSV File With JavaScript In Salesforce Lightning Component.
- http://www.sfdcmonkey.com/2017/04/19/download-csv-file-data-salesforce-lightning-component/
- https://salesforce.stackexchange.com/questions/150498/export-data-as-csv-from-lightning-component
Hope it will be helpful.Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.
Thanks
Rahul Kumar
On my blog i have displayed some data to user, User will select the data that user wants to download from the displayed data. Once user select all those record which user wants to export user has to click on download data button and excel in the csv format will get download.
Also i have shown how to show data from related object in csv as well.
Please refer the below link.
https://www.sfdc-lightning.com/2019/10/export-to-csv-in-lightning-component.html