Apex Controller:
public class table {
public PageReference Export() {
PageReference p = Page.RenderAsPDF1;
p.setRedirect(true);
return p;
//return null;
}
//constructor
public table()
{
}
public List<Account> accounts
{
get {
if(accounts != null)
{
return accounts;
}
else
{
accounts = [Select Id, Name,BillingState, Phone, Website from Account ];
return accounts;
}
}
set;
}
}
Visualforce Page:
<apex:page sidebar="false" tabStyle="Account" controller="table" >
<apex:form >
<apex:sectionHeader title="Account Details"/>
<apex:pageBlock title="All Account">
<apex:pageBlockTable value="{!accounts}" var="acc">
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.BillingState}"/>
<apex:column value="{!acc.Phone}"/>
<apex:column value="{!acc.Website}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
No comments:
Post a Comment