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
MarkL.ax269MarkL.ax269 

Export full result set from StandardSetController

I'm creating a VisualForce page that displays the results from a query using a custom list controller. The purpose is to give the users a report that can't be created with standard reporting. It's a "does not have child object" report, but I can't use rollup summaries because the criteria has to include the result of a formula field on the child. This would be so much easier if reports could be based on a SOQL statement (hint hint).

My query will return potentially thousands of records and displaying them in the VF page with a paginator works great. However I want to give them the option to export the full result set to Excel, much like a standard report will. Unfortunately getRecords only returns what's in the current page set. How can I get the full result set (up to 10,000 of course) exported to Excel?

Mark
Best Answer chosen by Admin (Salesforce Developers) 
MarkL.ax269MarkL.ax269

In case anyone is curious, I solved this by resetting the page size of the list controller when exporting to excel. I used a simple boolean to let the controller know to set the page size to 100 for the screen, or to the full result size for excel.  It's working well for result sets > 1000.

 

 

this.excel = true;
setCon.setPageSize(setCon.getResultSize());

 

 

 

All Answers

MarkL.ax269MarkL.ax269

In case anyone is curious, I solved this by resetting the page size of the list controller when exporting to excel. I used a simple boolean to let the controller know to set the page size to 100 for the screen, or to the full result size for excel.  It's working well for result sets > 1000.

 

 

this.excel = true;
setCon.setPageSize(setCon.getResultSize());

 

 

 

This was selected as the best answer
Santhosh341Santhosh341

Will u please send me the Code for Exporting to Excel 10,000 records