You need to sign in to do that
Don't have an account?
prevent to redirect to the page on Excel Export
In my main VF page, there is drop down menu which allows to choose different pages.
and command button 'Export Excel'.
<apex:include pageName="{!selectedPageName}"/>
Each Included Differnt VF page will show data according to the search criteira on the its page itself.
My requirement is when Export Excel command button is clicked, the selected Page will be downloded with criteria as Excel sheet (but exclude command button other criteria objects).
Currently my approach is I created second page (without command button or other criteria objects), only data which need to display in excel.
Code is as following.
PageReference OpenNewPage = New Pagereference('/apex'+'/PageA_SecondPageAsExcel');
OpenNewPage.setRedirect(false);
return OpenNewPage;
The issue is when Export Excel command button is clicked, the page go from PageA_Main to PageA_SecondPageAsExcel and show blank.
I want to avoid going to the Second page and showing blank page. But I want to export Excel too.
What kind of approach should I take? (any input will be so helpful for me).
Thanks ahead.
Kudo to this link. http://salesforce.stackexchange.com/questions/12009/apexinclude-and-pagereference-issue
All Answers
Hi,
You have a second page ,only data which need to display in excel.
have you use contentType="application/vnd.excel#download.xls" attribute in this VF.If you use this in your VF page which u want to download.
then write
PageReference OpenNewPage = Page.PageA_SecondPageAsExcel;
OpenNewPage.setRedirect(false);
return OpenNewPage;
it download the excel page and not redirect .
Please lete me know if u have any problem on same and if this post helps u give KUDOS by click on star at left.
Hi, I am still gettting the blank page even I used your suggested code.
The code I provided also can download as Excel, only redirected to Blank page. Still facing the same.
Is is because of <apex:include> ? If I directly access the 1st page and download the second page is ok.
As I am using Main Page, which use include tag, I suspect it.
Any idea? Thanks ahead .
Waiting for everyone's input.
Kudo to this link. http://salesforce.stackexchange.com/questions/12009/apexinclude-and-pagereference-issue