前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Salesforce VisualforcePage取得标准ListView生成CSV文件(四)

Salesforce VisualforcePage取得标准ListView生成CSV文件(四)

原创
作者头像
repick
修改2023-03-24 17:07:40
6520
修改2023-03-24 17:07:40
举报
文章被收录于专栏:SalesforceSalesforce

关于取得标准ListView数据的方法前边已经讲过了,下边使用VisualforcePage看如何生成CSV文件。

1.Apex类跟之前一样,使用【getRecords】方法取得所有标准listview的数据。

ListViewDownloadController.cls

代码语言:javascript
复制
public with sharing class ListViewDownloadController {
    public List<Account> accounts{get;private set;}
    public ListViewDownloadController(ApexPages.StandardSetController stdSetController){
        List<Account> accs = new List<Account>();
        Integer count = 0;
        do {
            count++;
            stdSetController.setpageNumber(count);
            system.debug('>>>>>>>>>>>>>>getPageNumber()>>>>>>>>>>>>>>>>>>>' + stdSetController.getPageNumber());
            for (Account acc : (List<Account>) stdSetController.getRecords()) {
                accs.add(acc);
                system.debug('>>>>>>>acc.Id>>>acc.Name>>>>>>>>>>>>>>>>>>>' + count + '>>>>>>' + acc.Id + '>>>'+ acc.Name);
            }
            system.debug('>>>>>>>>>>>>>>accs>>>>>>>>>>>>>>>>>>>'+accs.size());
            system.debug('>>>>>>>>>>>>>>getHasNext>>>>>>>>>>>>>>>>>>>'+stdSetController.getHasNext());
            system.debug('>>>>>>>>>>>>>>getPageSize()>>>>>>>>>>>>>>>>>>>'+stdSetController.getPageSize());
        } while (stdSetController.getHasNext());
        accounts = accs;
    }
}

2.VisualforcePage做成

getAccountListDownloadForVf.page

代码语言:javascript
复制
<apex:page standardController="Account" recordSetVar="accounts" extensions="ListViewDownloadController"
  cache="true" contentType="text/csv;charset=Shift_JIS;#exportAccountList.csv">
    "Name","従業員数","業種","説明"
    <apex:repeat value="{!accounts}" var="item">
      "{!item.Name}","{!item.NumberOfEmployees}","{!item.Industry}","{!item.Description}"
    </apex:repeat>
</apex:page>

getAccountListDownloadForVf.page-meta.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>56.0</apiVersion>
    <availableInTouch>false</availableInTouch>
    <confirmationTokenRequired>false</confirmationTokenRequired>
    <label>getAccountListDownloadForVf</label>
</ApexPage>

3.Listbutton做成

4.效果展示

exportAccountList.csv

5.关于制限

当做成1000件数据时,可以正常做成CSV文件

当做成1001件数据时,跟之前一样,不能正常生成csv文件。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档