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
Vishwas B NVishwas B N 

Export data to CSV using LWC and APEX

HI team,

I have a requirement to export data into .csv from salesforce app.

We are using external API's to get the data from extrenal db and display it in table using LWC.

Now we want to exoprt the data showed in LWC to .csv file.

Can anyone help how can we achieve this using LWC and Apex.

Thank you.

Best Answer chosen by Vishwas B N
VinayVinay (Salesforce Developers) 
Hi Vishwas,

Check below examples.

https://www.apexhours.com/export-to-csv-xls-using-lightning-web-component/
https://www.salesforcecodecrack.com/2019/05/export-data-as-csv-file-with-javascript.html
https://www.salesforcetroop.com/generate_csv_in_lwc

Hope above information was helpful.

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

Thanks,

All Answers

VinayVinay (Salesforce Developers) 
Hi Vishwas,

Check below examples.

https://www.apexhours.com/export-to-csv-xls-using-lightning-web-component/
https://www.salesforcecodecrack.com/2019/05/export-data-as-csv-file-with-javascript.html
https://www.salesforcetroop.com/generate_csv_in_lwc

Hope above information was helpful.

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

Thanks,
This was selected as the best answer
Dhanik L SahniDhanik L Sahni
Hello,
If you are looking for saving data in old(XSL/CSV) and new Excel format (XSLS) then check out this post Export Data from Lightning Web Component to Excel Sheet (https://salesforcecodex.com/salesforce/export-data-from-lightning-web-component-to-excel-sheet/)

Thank You,
Dhanik