您的位置:首页 > 产品设计 > UI/UE

salesforce csv 1000 limitation issue

2015-06-25 15:35 645 查看
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:

view
source

print?

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.

June 7, 2012

·

Like

1

·

Dislike

0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: