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

From a VisualForce Page, click a button and export/save the panelGrid to Excel
I have found multiple posts on how to edit the apex:page line so that when the VF page is activated, it saves itself to an excel file:
<apex:page cache="true" contentType="application/vnd.ms-excel#test.xls" controller="StoreController" language="english">
But what I need to do is display the VF page with the panelGrid. Then the user can click a button or link that will export the grid to excel.
I was thinking of just creating a second visualforce page that contains the above apex:page line, but I don't know how to add that logic to a button/link.
Thanks
Todd
I think I figured this out. I created a second VF page and then in my cls file, I added this method:
public PageReference save()
{
return page.FiscalReportToExcelPage;
}
this then calls the new VF page with the apex:page information directing it to be exported to excel. Works like a charm.
Todd
All Answers
Yes you will need two Visualforce pages or you may put the button as a custom button on a standard layout that launches the page that exports to Excel.
I think I figured this out. I created a second VF page and then in my cls file, I added this method:
public PageReference save()
{
return page.FiscalReportToExcelPage;
}
this then calls the new VF page with the apex:page information directing it to be exported to excel. Works like a charm.
Todd
Hi folks,
My requirement is: I've developed some code with an Apex Controller and a Visualforce page.The Visualforce page contains 3 picklist fields and a "Show" button.Once all these 3 picklist values were selected and clicked on "Show" button then a table of data with 3 colomns will be displayed.Up to here everything is fine.
Then I should have an "Export" button which exports the entire table data into an Excel.
I would be very thankful to you if you explain the idea of second VF page in Detail.
Jagadeesh K.
Hi,
I think you have used form tag in ur visualforce page, please remove the form tag and export u will not get calender values.
https://nitinkhunalsalesforce.wordpress.com/2016/10/27/visualforce-export-excel-report-using-remote-action-and-alasql/
You can export excel using javascript remoting, For this you don't need to create additional visualforce page to renderAs excel.