Skip to main content
CRMSalesforce CRM

Open Visual Force Page in Microsoft Excel

By December 27, 2020No Comments

Having a visual force page open in Microsoft Excel can come in handy for exports, reports, and merges.

When creating your visual force page, add the following to top <apex:page> section:

<apex:page standardController=”Contact” contentType=” application/vnd.ms-excel#Demo Example.xls” showHeader=”false” standardStylesheets=”false” > 

ContentType controls the application that will open the page.  Be sure to include showHeader = “false” and standardStylesheets=”false”.

Finally, add your page block section and return the values to the page (this code will list contact name, email, and phone for the household):

</apex:pageBlock>

<apex:pageBlock title=”Contacts”>

<apex:pageBlockTable value=”{!account.Contacts}” var=”contact”>

<apex:column value=”{!contact.Name}”/>

<apex:column value=”{!contact.Email}”/>

<apex:column value=”{!contact.Phone}”/>

</apex:pageBlockTable>

</apex:pageBlock>

</apex:page>

Test the page and see if it will open automatically in Excel (newer versions).  Otherwise it will download and then click to open it.  You may have to change the View and Enable editing.

Becci MG

Author Becci MG

More posts by Becci MG

Leave a Reply

5 Great Alternatives to SalesForce.com

Free Whitepaper Download

Learn more about 5 options that are better CRMs for small business

DOWNLOAD WHITEPAPER

Skip to content