1

I'm trying to rendering a VF page as an excel file and css classes are not being applied when you have something referencing multiple css classes.

Example:

<apex:page
    showHeader="false"
    sidebar="false"
    standardStylesheets="false"
    applyBodyTag="false"
    applyHtmlTag="false"
    contentType="application/vnd.ms-excel#test.xls"
>
<html>
<head>
<style>
    .oneStyle {
        background-color: #f00;
    }  

    .anotherStyle {
        color: #0f0;
    }
</style>
</head>
<body>
<table>
<tr>
    <td class="oneStyle">Works</td>
    <td class="anotherStyle">Works</td>
    <td class="oneStyle anotherStyle">Doesn't work at all, no styles</td>
</tr>
</table>
</body>
</html>

</apex:page>

I can get around this by by doing inline styling or doing something weird like creating lots of combo styles (ex. oneStyle-anotherStyle) but that's all pretty ridiculous.

Has anyone run into this before? Known issue? I don't expect the Excel rendering engine in Salesforce to be super robust, but this seems like pretty basic CSS support.

Using Summer '15, API v34

1 Answer 1

2

Salesforce is emitting the HTML you are instructing it to by the markup you include in your page. All that the contentType setting is doing is adding a header that your browser recognises and so forwards the HTML content to Excel. Effectively you've declared that Excel can handle the data.

So it is Excel's limited ability to convert CSS styled HTML into its own formatted spreadsheet cells that you are seeing. It isn't surprising that Excel can only handle simple CSS.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .