Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Visualforce CSV Example. Note the 'contentType' page attribute and the # to specify the file name.
<!--
This page must be accessed with an Account ID in the URL.
For example: https://<salesforceInstance>/apex/ContactsCsvPage?id=001D000000JRBet
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_styling_content_type.htm
-->
<apex:page standardController='Account' contentType='application/vnd.ms-excel#contacts.xls'>
<apex:pageBlock title='Contacts'>
<apex:pageBlockTable value='{!account.Contacts}' var='contact'>
<apex:column value='{!contact.Name}'/>
<apex:column value='{!contact.MailingCity}'/>
<apex:column value='{!contact.Phone}'/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
@douglascayers

This comment has been minimized.

Copy link
Owner Author

douglascayers commented Jan 2, 2017

Code snippet for my blog post about the many ways to export Salesforce data to CSV: https://douglascayers.com/2016/03/20/salesforce-easy-ways-to-export-data-as-csv/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.