http://salesforce.stackexchange.com/questions/69555/view-state-error-while-creating-generating-an-csv-file
https://developer.salesforce.com/forums/?id=906F00000008xtsIAA
http://salesforce.stackexchange.com/questions/69555/view-state-error-while-creating-generating-an-csv-file
https://developer.salesforce.com/forums/?id=906F00000008xtsIAA
You can use a list of lists and nested repeaters to get around the 1000 records in a list limit. Here's an example:
Controller
01
public
class
exportCSVController {
02
03
public
List
<
List
<myClass
>
>
myList {
get
;set;}
04
05
public
exportCSVController() {
06
myList
=
new
List
<
List
<myClass
>
>
();
07
List
<myClass
>
temp
=
new
List
<myClass
>
();
08
09
for
(Integer i
=
0
; i
<
2500
; i++){
10
if
(temp.size()
<
1000
){
11
myClass m
=
new
myClass();
12
m.val
1
=
'val1 '
+ i;
13
m.val
2
=
'val2 '
+ i;
14
temp.add(m);
15
}
16
else
{
17
myList.add(temp);
18
temp
=
new
List
<myClass
>
();
19
myClass m
=
new
myClass();
20
m.val
1
=
'val1 '
+ i;
21
m.val
2
=
'val2 '
+ i;
22
temp.add(m);
23
}
24
}
25
myList.add(temp);
26
}
27
28
29
public
class
myClass{
30
public
string val
1
{
get
;set;}
31
public
string val
2
{
get
;set;}
32
}
33
}
VisualForce Page:
1
<apex:page
controller=
"exportCSVController"
cache=
"true"
contentType=
"text/csv#Export.csv"
language=
"en-US"
>
2
"Col A"
,
"Col B"
3
<apex:repeat
value=
"{!myList}"
var=
"a"
>
4
<apex:repeat
value=
"{!a}"
var=
"asub"
>
5
"{!asub.val1}"
,
"{!asub.val2}"
6
</apex:repeat
>
7
</apex:repeat
>
8
</apex:page
>
This should allow you to have up to 10,00,000 records.