RSS

generate CSV file in SFDC Apex

12 Jun

To generate CSV file through Apex is fairly simple. Following steps will help you to understand it.

  •  Create a Controller and write a method which returns List of items.
public class generateCSVController{
   public List LeadList{get;set;}
    public generateCSVController(){
             //Populate List here.
              LeadList = [select id,name,email from lead limit 10];
    }
}
  • Create a page and associate it with the controller we created in first step.  Set the content type of the page to “text/csv”.
< apex:page controller="generateCSVController" cache="true"  contentType="text/csv#Leads.csv" language="en-US" >"Id","Names","Email"
< apex:repeat value="{!LeadList}" var="L" >
"{!L.id}","{!L.name}","{!L.email}"
< /apex:repeat >
< /apex:page >
Advertisements
 
Leave a comment

Posted by on June 12, 2012 in salesforce, TechIssues

 

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

 
%d bloggers like this: