3

Another VF excel issue. I'm outputting RichText fields in my VisualForce export like this:

<apex:column>     
                            <apex:facet name="header">Transaction Facts</apex:facet>    
                            <apex:outputText value="{! a.DRC_Account__r.Transaction_Facts__c }"  escape="true"/>
                        </apex:column>

                        <apex:column>     
                            <apex:facet name="header">Transaction Updates</apex:facet>  
                            <apex:outputText value="{! a.DRC_Account__r.Transaction_Updates__c }"  escape="true"/> 
                        </apex:column>

When output as PDF or HTML it's fine, however when exporting to Excel I get stuff like this

⢠Expecting to receive detailed information on the opportunity this week
3
  • The problem is most likely related to how Salesforce exports to Excel. If you were to save the exported Excel file to disk and open it in a text editor you would find it is using HTML tables to hold the data rather than the native Excel file format. Excel in turn is interpreting that HTML table into cell data. I see you have escape="true" on the apex:outputText elements. That seems like a good start. What do the RichText fields look like in the text editor? Are there other charaters that need to be HTML encoded? Aug 10, 2015 at 23:43
  • thanks Dan, not sure exactly what will be in the Rich text. Most likely bullets will be the main formatting I thnk Aug 11, 2015 at 9:54
  • 1
    Cracked it @DanielBallinger - see my answer. Glad I didn't need to get into encoding. Thanks for responding and supporting. Aug 13, 2015 at 21:00

1 Answer 1

4

Ok this is the working solution

<apex:page controller="AccountReportConfiguratorController"  
        contentType="application/vnd.ms-excel; charset=Windows-1252#Report.xls " 
        standardstylesheets="false" 
        language="en-US"
        showHeader="false"
    sidebar="false"
        readOnly="true"
        cache="true"
        >

The critical piece is this charset=Windows-1252

You must log in to answer this question.

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