How to print a Visualforce page in Salesforce?
Sample Code:
Visualforce page:
<apex:page showHeader="false" controller="Sample" >
<apex:panelGrid width="100%" style="text-align:right;">
<apex:form >
<apex:commandLink value="Print" onclick="window.print();"/>
</apex:form>
</apex:panelGrid>
<apex:pageBlock title="Member Information">
<apex:pageBlockTable value="{!MemberList}" var="m">
<apex:column value="{!m.Name}"/>
<apex:column value="{!m.City__c}"/>
<apex:column value="{!m.Country__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Apex Controller:
public class Sample {
public List<Member__c> memberList {get;set;}
public Sample() {
memberList = new List<Member__c>();
memberList = [SELECT Name, City__c, Country__c FROM Member__c];
}
}
Output:
Visualforce page:
<apex:page showHeader="false" controller="Sample" >
<apex:panelGrid width="100%" style="text-align:right;">
<apex:form >
<apex:commandLink value="Print" onclick="window.print();"/>
</apex:form>
</apex:panelGrid>
<apex:pageBlock title="Member Information">
<apex:pageBlockTable value="{!MemberList}" var="m">
<apex:column value="{!m.Name}"/>
<apex:column value="{!m.City__c}"/>
<apex:column value="{!m.Country__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Apex Controller:
public class Sample {
public List<Member__c> memberList {get;set;}
public Sample() {
memberList = new List<Member__c>();
memberList = [SELECT Name, City__c, Country__c FROM Member__c];
}
}
Output:
No comments:
Post a Comment