Data export from app on app exchange

I have a SFDC App which does data (Account, Contact, Lead) segmentation and flags them according to segmentation rules. I want to be able to provide a link on visualforce page to download certain accounts/contacts/leads (according to flag) in csv/excel(whichever is easy to do) format. How to do it?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You can use following for your purpose

<!-- Your Main Page -->
<apex:page controller="DownloadData">
<apex:form >
<apex:commandButton value="DownloadRecords" action="{!records}"/>

<!-- -Your DownloadDemo Page- -->
<apex:page controller="DownloadData"  contentType="application/" >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!data}" var="d">
<apex:column value="{!d.ID}"/>
<apex:column value="{!d.Data__c}"/>

/*****Same Controller for both the classes*****/
 public with sharing class DownloadData {

public PageReference records() 
   return new PageReference('/apex/DownloadDemo');

public List<MyObject__c> getData() {

    List<MyObject__c> mo = [SELECT ID,Data__C FROM MyObject__c];

    return mo;

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x