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, 2020 at 14:11

0

You must log in to answer this question.

Browse other questions tagged .