I am generating an excel file from VF page. I would need some help in formating the excel sheet.
Can the width of the cells in the top row be different from the cells of the tables in the bottom. Something like we merge a few columns in Row A of excel sheet.
Here is my VF page
<apex:page standardController="Quote" extensions="CVFE_GenerateExcelQuote" contentType="application/vnd.ms-excel#SalesForceExport.xls" cache="true" >
<!-- contentType="application/vnd.ms-excel#SalesForceExport.xls" cache="true" -->
<head>
<style>
.aligncenter
{
text-align:center;
}
</style>
</head>
<table>
<tr>
<td colspan="2">
<table>
<tr>
<td style="width:500px; height: 95px;">
<img src="{!url}" /> <br/>
</td>
</tr>
<tr>
<td>
Some Addrress
</td>
</tr>
</table>
</td>
<td width="100px">
</td>
<td width="100px">
</td>
<td width="100px">
</td>
<td>
<table>
<tr>
<td >John Doe</td>
<td >Billing</td>
<td >Traffic</td>
<td >Ad Ops</td>
</tr>
<tr>
<td >Vice President Sales</td>
<td >billing@a.com</td>
<td >Traffic@a.com</td>
<td >AdOps@a.com</td>
</tr>
</table>
</td>
</tr>
</table>
<apex:repeat value="{!OptionsSet}" var="f">
<apex:outputText value="{!f}" /><br/>
<apex:dataTable value="{!MapOptionQLI[f]}" var="s" style="border: 1px solid black;">
<apex:column value="{!s.Placement_Name__c}" />
<apex:column value="{!s.Start_Date__c}" style=" text-align:center;"/>
<apex:column value="{!s.End_Date__c}" style=" text-align:center;"/>
<apex:column value="{!s.Ad_Format__c}" style=" text-align:center;"/>
<apex:column value="{!s.Targetting__c}" style=" text-align:center;"/>
<apex:column value="{!s.Additional_Targetting__c}" style=" text-align:center;"/>
<apex:column style=" text-align:center;">
<apex:facet name="header">Rate</apex:facet>
<apex:outputfield value="{!s.UnitPrice}"/>
</apex:column>
<apex:column style=" text-align:center;">
<apex:facet name="header">Impressions</apex:facet>
<apex:outputfield value="{!s.Quantity}"/>
</apex:column>
<apex:column style=" text-align:center;">
<apex:facet name="header">CPM/CPC</apex:facet>
<apex:outputfield value="{!s.Rate_Type__c}"/>
</apex:column>
<apex:column value="{!s.Total_Investments__c}" style=" text-align:center;"/>
<apex:column value="{!s.Notes__c}" />
</apex:dataTable>
</apex:repeat>
</apex:page>
Best Answer
I haven't tried it, but take a look at this.
Instead of using HTML tags, it uses tags that are recognised by Excel.
In terms of XML markup, I think that page is slightly wrong, this seems like a good example of how to style columns: