Following is my page
<apex:page controller="contactquery" contentType="application/vnd.ms-excel#SalesForceExport.xls" cache="true">
<apex:pageBlock title="Export Results" >
<apex:pageBlockTable value="{!cs}" var="contact">
<apex:column value="{!contact.ID}"/>
<apex:column value="{!contact.Name}"/>
<apex:column value="{!contact.phone}"/>
</apex:pageBlockTable>
<apex:pageBlockTable value="{!acc}" var="account">
<apex:column value="{!account.id}"/>
<apex:column value="{!account.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
And following is my controller
public class contactquery{
public List<Contact> cs{get; set;}
public List<Account> acc{get; set;}
public contactquery()
{
cs = new List<Contact>();
acc = new List<Account>();
for (Account a : [Select id, Name,(Select id, Name from Contacts) from Account])
{
acc.add(a);
}
}
}
I get an excel sheet for accounts only.
PROBLEM: Unable to display contacts related to every account in a separate column. How can I achieve this? Thanks in advance.
UPDATE: Following is the required sample excel(without borders).
cs
list?