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
N@niN@ni 

Exporting Data from visualforce using command button.

I created one vf page, I am showing records in pageblock table, now i want to export data to  Excel, whenever click the command button.

 

 

plz help me.................

liron169liron169

You can create same page as you use to show the data in SF,  only as excel:

 

<apex:page controller="className" contentType="application/vnd.ms-excel">

 

 

The button (in your current page) will open the excel page:


<apex:outputlink target="_blank" value="/apex/ExcelPageName" >
      <apex:outputText value="Export To Excel" />
</apex:outputlink>

 

 

vbsvbs

You do not have to setup a separate page to render the current markup to Excel. You could dynamically change the contenttype to one specified above based on a formula to render this page to excel.