You need to sign in to do that
Don't have an account?
Ravi Roy
Export pageBlock table content from vf to csv using action button
In my visualforce I'm showing a large data of table using pageBlock table. I want to have a button on visual force page on which if i click then all the records within pageblock table should get export. I'm trying hard but not able to do please show it by some example.
Don't forget using myString.escapeCsv() for the 2012 sample:
http://salesforceapexcodecorner.blogspot.fr/2012/03/export-in-csv-and-excel-in-apex.html
https://douglascayers.com/2016/03/20/salesforce-easy-ways-to-export-data-as-csv/
escapeCsv(): Returns a String for a CSV column enclosed in double quotes, if required.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm
A simple way should be using a javascript plugin with jQuery because the pageBlock table is a html table. If there is an ID, this table is accessible for jQuery as any other component of the DOM:
http://www.jqueryscript.net/table/jQuery-Plugin-To-Convert-HTML-Table-To-CSV-tabletoCSV.html
Regards