function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Worksheets in Excel

I am able to create an Excel file with data from Salesforce using a VF page.  I need to be able to put some data on Worksheet 1 and other data on Worksheet 2.  Is it possible to specify the worksheet?


If not, how would I do this?


Thanks for any ideas...


You can specify a different format for a Visualforce page by using the ContentType attribute on the <apex:page> tag.
The ContentType attribute takes a Multipurpose Internet Mail Extension (MIME) media type as a value, such as
application/, audio/mpeg or image/gif. For more information about valid MIME media types, see

To display this page in Excel, add the contentType attribute to the <apex:page> tag, as follows:
<apex:page standardController="Account" contenttype="application/">
<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}"/>
If the page does not display properly in Excel, try a different content-type, such as text/rtf.
Thanks, I have that part working.  What I can't do in a VF page is create a second worksheet. I can do it in javascript and I think that is what I will wnd up doing. 

Have you found a solution to this using visualforce?  I am looking to do the same thing


No sorry.  The client doesn't use this functionality any longer so I didn;t do anything further.


Hi  am also having same problem 

If you found solution please let me know



thank you