function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Manu@devManu@dev 

Styles were not applied when I downloaded the VF page in Excel Format

Hi all,

I have developeed a VF page and  downloading the page in excel format on button click using contentType="application/vnd.ms-excel#FILENAME.xls" cache="true"

Please note that my entire page is in HTML table format using the style attributes and style classes.

After downloading the excel file, I am unable to see any style which I have mentioned in the VF Page.  For eg. The background color of the page is Red and when I downloaded it is normal in excel file. 

Can someone please help me to overcome this problem ?


Thanks,
Manu
Vatsal KothariVatsal Kothari
Hi Manu,

 Can you please share your code?

Thanks,
Vatsal
Manu@devManu@dev
Hi Vatsal,


Here is the code ..



<apex:page standardController="Account"  applyBodyTag="false" applyHtmlTag="false"  standardStylesheets="false" showHeader="false" contentType="application/vnd.ms-excel#FILENAME.xls" cache="true" >
<head>
    <style>
        .section1{
            background-color:red;
        }
   
    </style>
</head>
<body>
    <table  width="100%" class="section1">
        <tr>
            <td colspan="16" style="text-align:center"><b>Account Name</b></td>
        </tr>
</table>
</body>
</apex:page>


Please note that I am facing the followng problems -

1. The background color of table is not red.
2. The Label Account Name is not aligned to Center.

Thanks,
Manu
Vatsal KothariVatsal Kothari
But I am getting proper output.

User-added image
Manu@devManu@dev
Vatsal,

Not sure how come this is working for you but still not working for me. I am downloading .xls file and opening through open office, no styles were visible.  Can you tell me how you have opened the file(using MS-Excel?)

Thanks,
Manu