I have two VF pages one to display a list of records on screen and other to export the list as csv file.

For the the page where i am displaying on the screen, i am using standard set controller and displaying data within a apex:repeat. which works great.

When i try to export to csv and call the VF page. it throws out the error

Collection size 1,768 exceeds maximum size of 1,000.

I have the Vf page for the export using readonly="true"

As per the documentation the

In addition to querying many more rows, the readOnly attribute also increases the maximum number of items in a collection that can be iterated over using components such as , , and . This limit increased from 1,000 items to 10,000.

VF page Code

<apex:page controller="CVFC_MasterOrder" contentType="application/vnd.ms-excel#{!filename}" cache="true" readOnly="true">
            <apex:repeat value="{!FieldsExp}" var="f"> 

            <apex:repeat value="{!MasterListExp}" var="m"> 
                <apex:repeat value="{!FieldsExp}" var="f"> 
                   <apex:outputPanel id="rec" rendered="{! If(f.Type == 'textarea' ,true,false) }">

                        <td>{!m[f]} </td>
                    <apex:outputPanel id="rec2" rendered="{! If(f.Type == 'date' ,true,false) }">

                            <apex:outputText value="{0,date,short}">
                                <apex:param value="{!m[f]}" /> 

                    <apex:outputPanel id="rec5" rendered="{! If(f.Type == 'boolean' ,true,false )}">
                        <apex:outputPanel id="rec3" rendered="{! If(m[f] == true ,true,false ) }" >
                            <td>Yes </td>
                        <apex:outputPanel id="rec4" rendered="{! If(m[f] == false ,true,false ) }" >
                    <apex:outputPanel id="rec1" rendered="{! If(f.Type != 'textarea' && f.Type != 'boolean' && f.Type != 'date',true,false) }">
                        <td><apex:outputfield value="{!m[f]}" /></td> 



Apex class Method

public pageReference exporttoxls()
     String query = CUtilityFunctions.generateQueryFromFieldSet('Master_Order__c','MasterOrderQuery',null,wherecondition);  
                query+= ' LIMIT 50000 ';
                System.debug('Query ' + query);
        MasterListExp =  database.query(query); 
        filename ='Masterorder'+ Datetime.now().format('yyMMddHHmmss') + '.xls';
   return new pageReference('/apex/exporttocsv');

Any workarounds to get rid of this error.

2 Answers 2


A simple solution - instead of list, use map collection type.

This works check this post Why can Visualforce iterate over >1000 item collection if it's a map?

  • 1
    Thats interesting...I will certainly check this out :) As per documentation the list should allow holding 10000 if the VF page is readonly right
    – Prady
    Commented Jun 18, 2018 at 7:51
  • yes @Prady if readonly then it will iterate over 10K. I saw already in your code that's why i gave this solution.
    – Ratan Paul
    Commented Jun 18, 2018 at 8:15
  • @Prady is this issue resolved?
    – Ratan Paul
    Commented Jun 23, 2018 at 11:55

You can create List of List which could hold up to 10,000 records (max).

Here is an example from my blog Visualforce with JQuery Datatable for sorting, pagination and handling 10000 records

You must log in to answer this question.

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