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
Suma GangaSuma Ganga 

Export to Excel giving blank page

Hi all,
i have a requirement like, have to export the data to Excel sheet and save it locally.
this part is working fine as per the requirement. but, the main is getting balnk page.
i have a export button in relatedlists, once click on the export button my main page is redirecting to excel_VFP and it is blank, excel is opening with correct data only.
After opening Excel i have to go back to my previous page for this i am using {!$currentpage.Parameters.Referer} in my Export_VFP.
but, no use of this. can anyone please help on this.
Shashikant SharmaShashikant Sharma
I would suggest to render the page excel_VFP normally and see the output. This will give you idea what is missing.

If you still can not resolve please share code.
Suma GangaSuma Ganga
Hi Shashikant,

i have 2 VF Pages(export_VFP & EXportExcel_VFP).
<apex:page controller="ExportRAIDController" showHeader="false" action="{!exportFun}"></apex:page>
<apex:page controller="ExportRAIDController" action="{!exportToExcel}" cache="true" contentType="application/" language="en-US" >
    <apex:pageBlock  >
    {!$CurrentPage.Parameters.Referer}  <!--  this line is to go back to the previous page. -->
        <apex:pageBlockTable value="{!objLst}" var="object">
            <apex:repeat value="{!flds}" var="field">
                <apex:column value="{!object[field]}"/>
Controller is::

exportFun is returning page ref. with the dynamic object name and dynamic fields to ExportExcel_VFP. from is opening the excel popup to open or save excel file. but, the page has to go back to provious page. how to achive this..

Thanks in advance.

Shashikant SharmaShashikant Sharma
How are you redirecting to the page, I think you should redirect it from javascript to open the page in new window. 
Suma GangaSuma Ganga
im just returning pageReference.
pageReference refreshPage = new pageReference('/apex/ExportExcel_VFP?objName='+objName+'&soql='+sql+'&recordId='+recordId);
return refreshPage;

in my is having the contentType="application/". so, im able to get the excel ..
but the main page was blank. after opening that, i have to redirect to previous page.
Shashikant SharmaShashikant Sharma
As you are rendering the navigated page as Excel the parent page gets blank, I think you should try to navigate with location.href once opening in new window.  Try once and see if it resolves the issue.
Suma GangaSuma Ganga
u mean that, location.href  i need to add in my VF?
am i correct...
Shashikant SharmaShashikant Sharma
Yes, i mean location.href .