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
Surender reddy SalukutiSurender reddy Salukuti 

visual force page 1

Hi every one,

actually i wrote visual force page 
<apex:page standardController="account" contentType="Application/vnd.ms-excel">
    <apex:form>
    <apex:pageblock title="account">
        <apex:pageBlockTable value="{!account.contacts}" var="contacts">
            <apex:column value="{!contact.name}"/>
            <apex:column value="{!contact.phone}"/>
      </apex:pageBlockTable>
        </apex:pageblock>
   </apex:form>
</apex:page>

actually my intention is i want to know how to use contentType in vf page and how it display .
i wrote above program previed this program i am ot geeting error
but it s not showing any out put.

please let me know if any one knows about it 

Thank you
surender reddy

 
sridhar v 7sridhar v 7
Try the below code. 

<apex:page standardController="account" contentType="application/vnd.ms-excel#SalesForceExport.xls">
    <apex:form>
    <apex:pageblock title="account">
        <apex:pageBlockTable value="{!account.contacts}" var="contacts">
            <apex:column value="{!contacts.name}"/>
            <apex:column value="{!contacts.phone}"/>
      </apex:pageBlockTable>
        </apex:pageblock>
   </apex:form>
</apex:page>
Jithesh VasudevanJithesh Vasudevan

Try this,

<apex:page standardController="account" contentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
    <apex:form>
    <apex:pageblock title="account">
        <apex:pageBlockTable value="{!account.contacts}" var="contacts">
            <apex:column value="{!contacts.name}"/>
            <apex:column value="{!contacts.phone}"/>
      </apex:pageBlockTable>
        </apex:pageblock>
   </apex:form>
</apex:page>
Ajay K DubediAjay K Dubedi
Hi Surender,
Please try the code. I hope you got the Idea from the above code:                                             
<apex:page standardController="Contact" recordSetVar="conObj"  contentType="text/csv">
   <apex:dataTable value="{!conObj}" var="con">
    <apex:column>
            <apex:outputText value="{!con.LastName}"/>
        </apex:column>
    </apex:dataTable>
</apex:page>
I hope you find the above solution helpful. If it does, please mark as Best
Answer to help others too.

Thanks,
Ajay Dubedi