I have a visualforce page in which there is a button called download.
If I click that button then it will download all the account records as text file.
For this use case how can I implement.
Do not redirect to another visualforce page
Can someone suggest some ideas to implement?
My vfp code:
<apex:page standardController="Account" extensions="AccountDownload" recordSetVar="accounts" sidebar="false">
<apex:form >
<apex:pageBlock title="Archiver For Account">
<apex:pageBlockSection >
<apex:commandButton action="{!Download}" value="download" id="theButton" /><br/>
<apex:outputPanel id="panel1" rendered="{!ren}">
<apex:pageBlockTable value="{!accounts}" var="ac">
<apex:column value="{!ac.Name}"/>
<apex:column value="{!ac.AccountNumber}"/>
<apex:column value="{!ac.AnnualRevenue}"/>
<apex:column value="{!ac.Phone}"/>
<apex:column value="{!ac.Type}"/>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class AccountDownload {
public boolean ren{get;set;}
public AccountDownload(ApexPages.StandardSetController controller) {
ren=false;
}
public PageReference Download(){
ren=true;
return null;
}
}