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

click on a button visual force page will be download as a excel file

hai in my visual force page three buttons are there pdf,word,excel.when ever click on pdf the page is render as pdf,click on word that same page will be download as word file,click on excel excel file will be downloaded for that i wrote a code like this 

<apex:page standardController="account" recordSetVar="account" renderAs="{!if($CurrentPage.parameters.isPdf == null, null, 'pdf')}" contentType="{!if($CurrentPage.parameters.isWord== null, null,'application/x-excel#FileName.doc')}" extensions="pwe">
<apex:form >
<apex:pageBlock >
<apex:pageblockButtons >
<apex:commandButton value="pdf" action="/apex/automatic_insert?isPdf=true"/>
<apex:commandButton value="word" action="/apex/automatic_insert?isWord=ture"/>
<apex:commandButton value="excel" action="{/apex/automatic_insert?isExcel=ture"/>
<apex:pageBlockTable value="{!account}" var="a">
  <apex:column value="{!}"/>
  <apex:commandButton action="{!save}" value="save"/>

but i am getting confusion with <apex:page> we can place any one contentType.when how can i get excel with this code please help me ony one
try this for excel -: 


i know contentType="application/" this is for excel generation.what i am asking is in the  same page i want to write code for both word genaration and excel genaration code.
Try this -: 

<apex:page standardController="account" recordSetVar="account" renderAs="{!if($CurrentPage.parameters.isPdf == null, null, 'pdf')}" contentType="{!if($CurrentPage.parameters.isWord == null, if($CurrentPage.parameters.isExcel == null, null ,'application/'),'application/x-excel#FileName.doc')}" >

Mark this as Solved if it resolves your query.
fine now it is working thank you abhi
Hariom Chaudhary 1Hariom Chaudhary 1
Hey, srilakshmi can you provide apex class for it ?
mulukutla pavanimulukutla pavani
Srilakshmi can you please provide apex class for this