You need to sign in to do that
Don't have an account?
SFDC_sadas
Custom Report to VF page
I am unable to display report in PDF format, only the Column the headings are displayed, any help please.
VF Page
<apex:page controller="reportclass" id="page" showHeader="false" Sidebar="false" cache="true" expires="1200" renderAs="pdf" >
<body >
<apex:pageBlock id="results" >
<!-- HTML Table used to display Candidate Data in PDF format -->
<table border="1" cellpadding="1" cellspacing="0" style="width:100%;border:1px solid #000000;font-familyans-serif;font-size:10px">
<tr style="font-family:verdana;color:Black;font-size:12px;height=18px;width:100%" >
<!-- Autofilter added for header row in PDF sheet -->
<td x:autofilter='all' style="background-color: #DAFFFF" ><b> <apex:outputText value="Date" /></b> </td>
<td x:autofilter='all' style="background-color: #DAFFFF" ><b><apex:outputText value="Subject"/></b> </td>
<td x:autofilter='all' style="background-color: #DAFFFF" ><b><apex:outputText value="Contact"/></b></td>
<td x:autofilter='all' style="background-color: #DAFFFF" ><b><apex:outputText value="Comments"/></b></td>
</tr>
<apex:repeat value="{!Opportunity}" var="c" id="InvRepeat">
<tr border="1" style="font-family:verdana;color:Black;font-size:12px;width:100%" >
<td ><apex:outputText value="{!c.name}"/></td>
<td><apex:outputText value="{!c.Fund_Name__c}"/></td>
<td><apex:outputText value="{!c.CloseDate}"/></td>
<td><apex:outputText value="{!c.Amount}"/></td>
<td><apex:outputText value="{!c.StageName}"/></td>
</tr>
</apex:repeat>
VF Page
<apex:page controller="reportclass" id="page" showHeader="false" Sidebar="false" cache="true" expires="1200" renderAs="pdf" >
<body >
<apex:pageBlock id="results" >
<!-- HTML Table used to display Candidate Data in PDF format -->
<table border="1" cellpadding="1" cellspacing="0" style="width:100%;border:1px solid #000000;font-familyans-serif;font-size:10px">
<tr style="font-family:verdana;color:Black;font-size:12px;height=18px;width:100%" >
<!-- Autofilter added for header row in PDF sheet -->
<td x:autofilter='all' style="background-color: #DAFFFF" ><b> <apex:outputText value="Date" /></b> </td>
<td x:autofilter='all' style="background-color: #DAFFFF" ><b><apex:outputText value="Subject"/></b> </td>
<td x:autofilter='all' style="background-color: #DAFFFF" ><b><apex:outputText value="Contact"/></b></td>
<td x:autofilter='all' style="background-color: #DAFFFF" ><b><apex:outputText value="Comments"/></b></td>
</tr>
<apex:repeat value="{!Opportunity}" var="c" id="InvRepeat">
<tr border="1" style="font-family:verdana;color:Black;font-size:12px;width:100%" >
<td ><apex:outputText value="{!c.name}"/></td>
<td><apex:outputText value="{!c.Fund_Name__c}"/></td>
<td><apex:outputText value="{!c.CloseDate}"/></td>
<td><apex:outputText value="{!c.Amount}"/></td>
<td><apex:outputText value="{!c.StageName}"/></td>
</tr>
</apex:repeat>
public with sharing class reportclass
{
public reportclass() {
}
public Account Account {get;set;}
//public Integer Total {get;set;}
public id Accountid {get;set;}
sobject ar;
public decimal total1 {get;set;}
public reportclass(ApexPages.StandardController controller)
{
this.Account = (Account)controller.getRecord();
this.Accountid =Account.id;
}
public list<contact> getContact()
{
list<contact> c=[select id,name,MailingCity,MailingState,MailingCountry,MailingPostalCode,MobilePhone,Phone,Email from contact where accountid=:Accountid ];
return c;
}
public list<Task> getActivity()
{
list<Task> c=[select ActivityDate,Subject,Whoid,Description from Task where Whatid=:accountid ORDER BY ActivityDate ASC];
return c;
}
public list<Opportunity> getOpportunity()
{
list<Opportunity> c=[select id,Name,CloseDate,Amount,Fund_Name__c,StageName from Opportunity where accountid=:accountid ORDER BY CloseDate ASC];
return c;
}
public sobject getTotal()
{
ar=[select sum(Amount)sum from Opportunity where accountid=:accountid ];
total1= (decimal)ar.get('sum');
return ar;
}
public pagereference Download(){
PageReference exdownload = null;
exdownload = Page.ExcelDownload;
exdownload.setRedirect(false);
getContact();
return exdownload ;
}
public pagereference DownloadPDF(){
PageReference PDFdownload = null;
PDFdownload = Page.PDFDownload;
PDFdownload.setRedirect(false);
getContact();
return PDFdownload ;
}
}
modify the page like this and change headers as you like
<apex:page controller="reportclass" id="page" showHeader="false" Sidebar="false" cache="true" expires="1200" renderAs="pdf" >
<body >
<apex:pageBlock id="results" >
<!-- HTML Table used to display Candidate Data in PDF format -->
<table border="1" cellpadding="1" cellspacing="0" style="width:100%;border:1px solid #000000;font-familyans-serif;font-size:10px">
<tr style="font-family:verdana;color:Black;font-size:12px;height=18px;width:100%" >
<!-- Autofilter added for header row in PDF sheet -->
<td style="background-color: #DAFFFF" ><b> <apex:outputText value="Date" /></b> </td>
<td style="background-color: #DAFFFF" ><b><apex:outputText value="Subject"/></b> </td>
<td style="background-color: #DAFFFF" ><b><apex:outputText value="Contact"/></b></td>
<td style="background-color: #DAFFFF" ><b><apex:outputText value="Comments"/></b></td>
</tr>
<apex:repeat value="{!Opportunity}" var="c" id="InvRepeat">
<tr border="1" style="font-family:verdana;color:Black;font-size:12px;width:100%" >
<td ><apex:outputText value="{!c.name}"/></td>
<td><apex:outputText value="{!c.CloseDate}"/></td>
<td><apex:outputText value="{!c.Amount}"/></td>
<td><apex:outputText value="{!c.StageName}"/></td>
</tr>
</apex:repeat>
</table>
</apex:pageBlock>
</body>
</apex:page>
let me know if it helped
part of vf page:
<apex:page controller="reportclass" id="page" showHeader="false" Sidebar="false" cache="true" expires="1200" renderAs="pdf" >
<body >
<apex:pageBlock id="results" >
<table border="1" cellpadding="1" cellspacing="0" style="width:100%;border:1px solid #000000;font-familyans-serif;font-size:10px">
<tr style="font-family:verdana;color:Black;font-size:12px;height=18px;width:100%" >
<!-- Autofilter added for header row in PDF sheet -->
<td style="background-color: #DAFFFF" ><b> <apex:outputText value="Name" /></b> </td>
<td style="background-color: #DAFFFF" ><b><apex:outputText value="Address"/></b> </td>
<td style="background-color: #DAFFFF" ><b><apex:outputText value="E-mail"/></b></td>
<td style="background-color: #DAFFFF" ><b><apex:outputText value="Home Phone"/></b></td>
<td style="background-color: #DAFFFF" ><b><apex:outputText value="Mobile Number"/></b></td>
</tr>
<apex:repeat value="{!Contact}" var="c" id="ConRepeat">
<tr border="1" style="font-family:verdana;color:Black;font-size:12px;width:100%" >
<td ><apex:outputText value="{!c.Name}"/></td>
<td><apex:outputText value="{!c.MailingCity}
{!c.MailingState}
{!c.MailingCountry}
{!c.MailingPostalcode}"/></td>
<td><apex:outputText value="{!c.Email}"/></td>
<td><apex:outputText value="{!c.Phone}"/></td>
<td><apex:outputText value="{{!c.MobilePhone}}"/></td>
</tr>
</apex:repeat>
</table>
<br/>
<br/>
<br/>
Controller
public with sharing class reportclass
{
public reportclass()
{
}
public Account Account {get;set;}
//public Integer Total {get;set;}
public id Accountid {get;set;}
sobject ar;
public decimal total1 {get;set;}
Public List<contact> CandidateList {get;set;}
public reportclass(ApexPages.StandardController controller)
{
this.Account = (Account)controller.getRecord();
this.Accountid =Account.id;
}
public list<contact> getContact()
{
list<contact> c=[select id,name,MailingCity,MailingState,MailingCountry,MailingPostalCode,MobilePhone,Phone,Email from contact where accountid=:Accountid];
CandidateList=[select id,name,MailingCity,MailingState,MailingCountry,MailingPostalCode,MobilePhone,Phone,Email from contact where accountid=:Accountid ];
return c;
}
public list<Task> getActivity()
{
list<Task> c=[select ActivityDate,Subject,Whoid,Description from Task where Whatid=:accountid ORDER BY ActivityDate ASC];
return c;
}
public list<Opportunity> getOpportunity()
{
list<Opportunity> c=[select id,Name,CloseDate,Amount,Fund_Name__c,StageName from Opportunity where accountid=:accountid ORDER BY CloseDate ASC];
return c;
}
public sobject getTotal()
{
ar=[select sum(Amount)sum from Opportunity where accountid=:accountid ];
total1= (decimal)ar.get('sum');
return ar;
}
public pagereference Download(){
PageReference exdownload = null;
exdownload = Page.ExcelDownload;
exdownload.setRedirect(false);
getContact();
return exdownload ;
}
public pagereference DownloadPDF(){
PageReference PDFdownload = null;
PDFdownload = Page.PDFDownload;
PDFdownload.setRedirect(false);
getContact();
return PDFdownload ;
}
}
I am getting output as shownn the image below.
I didnot get what the issue you are facing.Can u describe the issue clearly so that I can help you