Is it possible to export a custom contact view to Excel? I have a button that goes to the ExportContacts.page that is defined like:
<apex:page standardController="Contact" contenttype="application/vnd.ms-excel" recordSetVar="contacts" extensions="ExportContactsExtension" >
<apex:pageBlock title="Contacts">
<apex:pageBlockTable value="{!contacts}" var="contact">
<apex:column value="{!contact.LastName}"/>
<apex:column value="{!contact.FirstName}"/>
<apex:column value="{!contact.Name}"/>
<apex:column value="{!contact.MailingCity}"/>
<apex:column value="{!contact.Phone}"/>
<apex:column value="{!contact.Fax}"/>
<apex:column value="{!contact.MobilePhone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
The ExportContactsExtension.cls is defined like:
public class ExportContactsExtension {
public ExportContactsExtension(ApexPages.StandardSetController controller) {
//set the page size so all records will be exported
controller.setPageSize(controller.getResultSize());
}
}
The question is can I export the specific fields specified in the contacts view? On the ExportContacts.page, I have to define the fields to export, like last name, first name, etc. Now if I create a new contacts view and add say the email address, I'll see it on the page, but if I click the export button, it doesn't include the email address. Can I make that export dynamic to include all of the values from the current view?