0

It seems that every page that I rendered as excel the downloaded file is by default without gridlines.

I can go to the excel properties and check the option 'Gridlines', the I'm able to see the gridlines, but I'm checking how it can be automatically set to checked.

See example:

<apex:page StandardController="Account"  cache="true" 
        contentType="application/vnd.ms-excel#SalesForceExport.xls"
        showHeader="false" sidebar="false" standardStylesheets="false">

<apex:pageBlock >    
    <apex:pageBlockSection columns="1">
        <apex:pageBlockSectionItem >
            <apex:outputLabel value="Account Name" />
            <apex:outputText value="{!Account.Name}" />
        </apex:pageBlockSectionItem>


    </apex:pageBlockSection>


</apex:pageBlock>

</apex:page>

enter image description here

2
  • there is no flag for such things...I would suggest running this on some other system and open the excel file. Mar 26, 2018 at 4:48
  • Thanks. But actually already try on different computer, each with different Microsoft version
    – Liron C
    Mar 26, 2018 at 4:54

1 Answer 1

3

When we download Excel using default code(Like your) we don't get much styling and also the gridlines are missing as well.

To handle this you need to modify your code and need to create excel in visualforce using tag. You need to use Row, Call, Data tag to get proper style and gridlines.

<apex:repeat value="{!opportunities}" var="opp">
   <Row>
    <Cell ><Data ss:Type="String">{!opp.Name}</Data>
        <NamedCell ss:Name="Name_Column"/></Cell>
    <Cell ><Data ss:Type="String">{!opp.StageName}</Data>
        <NamedCell ss:Name="Stage_Column"/></Cell>
    <Cell ><Data ss:Type="Number">{!opp.Amount}</Data>
        <NamedCell ss:Name="Amount_Column"/></Cell>
    <Cell ss:StyleID="s75" ss:Formula="=IFERROR(RC[-1]/Total_Amount_Cell,0)"><Data
      ss:Type="Number"></Data>
        <NamedCell ss:Name="Percentage_of_Total_Column"/></Cell>
   </Row>
</apex:repeat>

Using these tag you can easily get output like

enter image description here

Reference : Stylish Spreadsheets From a Visualforce Page

2
  • @LironC yes it is. Mar 26, 2018 at 5:13
  • How can I edit the encoding of this document? I have special characters, which end up looking really bad (like: ???)...
    – Laureant
    Mar 29, 2019 at 12:23

You must log in to answer this question.

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