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

Posting Selected Data table Data in Excel from VisualForce page

Hello ,

I am trying to do some excel calculation  in Visual force page. after save that  some of the data table  need to Downloaded to Excel.sheet. Is there any possibility to export data to Excel with the whole Data table ?




Adam HowarthAdam Howarth



I am doing something similar.


The way I did it, was to create a new VisualForcePage as below:



<apex:page standardstylesheets="false" controller="YourController" contentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
	<apex:dataTable value="{!accounts}" var="account" id="theTable" rowClasses="odd,even"


		<apex:facet name="caption">table caption</apex:facet>

		<apex:facet name="header">table header</apex:facet>

		<apex:facet name="footer">table footer</apex:facet>


		        <apex:facet name="header">Name</apex:facet>

			<apex:facet name="footer">column footer</apex:facet>

			<apex:outputText value="{!}"/>



			<apex:facet name="header">Owner</apex:facet>

			<apex:facet name="footer">column footer</apex:facet>

			<apex:outputText value="{!}"/>




The important bit is contentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"



So I would


  • Create a link that opens in a new tab to the excel page.
  • Bind the table as you are doing in your current page.
  • When the link is clicked, an xslx file will be downloaded.