2

I am exporting a VF page as Excel document. While I export excel file, Image cell contains blank data. Below is my VF page code. It is working fine if I am using static url (<img alt="Image" src="https://myorgurl/resource/DefaultProfileImage" />) instead of dynamic Image url.

<apex:page controller="Users_Profile" contentType="application/vnd.ms-excel#Users.xls">
    <table border="0" cellspacing="0" cellpadding="0" style="width:100%;">
        <thead>
            <tr>
                <th>Profile Image</th>
                <th>Name</th>
                <th>City</th>
                <th>State</th>
            </tr>
        </thead>
        <tbody>
            <apex:repeat value="{!lstUsers}" var="user">
                <tr>
                    <td>
                        <img alt="Image" src="{!BaseUrl}{!URLFOR($Resource.DefaultProfileImage)}" />
                    </td>
                    <td>{!user.Name}</td>
                    <td>{!user.City__c}</td>
                    <td>{!user.State__c}</td>
                </tr>
            </apex:repeat>
        </tbody>
    </table>
</apex:page>

I have tried XML structure instead of HTML tags in VF page to get this resolved but it is not working. I referred following answered questions but did not get solution for this.

  1. Image not getting displayed in exported excel from VF page
  2. How to display image from Static Resource in Excel sheet (generated from VF Page)
1
  • If typing out the URL manually works, that makes me suspect the merge fields aren't constructing the URL appropriately and not that there is an issue with Excel rendering the image or a permissions issue around the image being shown in a spreadsheet. Can you check what the merge fields are constructing to verify that it is identical to typing in the URL manually? – nbrown Jun 18 '20 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.