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
J&A-DevJ&A-Dev 

Is it possible to export a visualforce page to excel on a button click?

Hi,

 

I'm aware of we can set the "contentType" attribute on the apex:page tag to export the current contents of the page to excel. But what if I have a button on the page that will change the content of the page? Is there a way to build an export from a button click?

 

Thanks in advance.

EnthEnth
Just make your button call a copy of the page with the Content Type set accordingly. Build the body of your page using a Component and the 2 pages will share the same code, so you don't have to worry about maintaining 2 copies.