I have a requirement where I want to render page as excel file with maximum 50000 records. I have tried all the below approaches but none of below are working. As a result now we need to create an admin process where support team person is going to download records using standard report.We have a sales force site, where visual force pages are added.On one of such page, there is some button on click which we need to achieve this functionality. Approaches already tried: 1. Wrapper class to display the records 2. Read Only attribute set to TRUE on Visual force page 3. List of List of Sobject in order to reduce the size of list on page(within limit on Sales force) 4. Displaying records in .csv format. 5. Calling the method returning required records using remote action.

If any one has worked on such requirement, kindly help me.

1 Answer 1


I did this by combining readonly, list of lists and remote action, and wrapper class.

The @RemoteAction @ReadOnly contains an inline query that builds a list of lists of wrapper classes. I'm not sure the wrapper class was necessary for the size of the query, I think it was just for convenience of displaying results from different objects.

A cutdown version of my apex, which is looking for contacts:

global static list<list<ConResult>> getCons()
    list<list<ConResult>> allCons = new list<list<ConResult>>();
    for (Contact con: [SELECT Name, Email FROM Contact ])
        if (allCons[allCons.size() -1].size() == 10000) allCons.add(new list<ConResult>());
        allCons[allCons.size() -1].add( new ConResult(con.Name, con.Email));
    return allCons;

My requirement was only for a one-off admin report, so in the Visualforce, the JSON returned from the remote action is written to the screen as CSV and the admin copy-pasted it into excel. It's not very elegant at that end.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .