You need to sign in to do that
Don't have an account?

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.

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.