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
ckellieckellie 

How do I create a visualforce excel worksheet from a dynamic page

I have a dynamic visualforce page where users will develope a list of records from three picklists. Once the user renders a list of records the user needs to open the page up in excel.

 

I have tried to create a extension to transfer the variables from the picklists to the new visualforce page, but have not been able to?

 

From a theoretical point, what do I need to do?

sfdc guy.ax723sfdc guy.ax723

Excel has an undocumented feature of understanding HTML Tables.

 

This code was in the Visual Developer Docs. Under the Index look for ContentType. This will output an HTML Table that will be streamed to Excel.

 

<apex:page standardController="Account" contenttype="application/vnd.ms-excel">
<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>
ckellieckellie

Thank you for the answer, though it is a portion of what I am looking for.

I am needing to include the reasults from picklist that I have on the original visualforce page. Translated, I have already queried and return the desired data, and it is displayed on the screen. How do I translate what is visible on screen to an excel file without requerying the database?

sfdc guy.ax723sfdc guy.ax723

You need to do this with 2 pages. The first page does all the data collection from your pick lists. The 2nd page is an output Template.

Make sure you use the same controller or controller / extension in both pages.

 

Step 1: Create a vf page that is your output template. Reference your vfClass that is doing the database quering from your first vfPage.

Step 2: On your first vf page create a button and method for the button.

 

<apex:commandbutton value"createOutput" action{!createOutput} />

 

In your controller you will have the following method

 

public Pagereference createOutput()

{

     return new Pagereference('myOutputTemplate');

}

 

If you don't need to show the results before you create the output document you could simply return the template page from the button that gets the data.

If you need complete code let me know.

 

sfdc guy

 

m.ddn.sh89m.ddn.sh89
hey! i have a visualforce page in which i get records after applying filters,means i get dynamic data on the visualforce page after the user apply desired filters
I want to get the result in excell.
Each time some user applies filter and get the records in visualforce page->click on export to excell button->get excell file.
PLZ HELP
Kt YadavKt Yadav
If you want to generate an excel from Salesforce Detail record page using VF and Apex please refer the below link.
http://wp.me/p98HXm-G