gpt4 book ai didi

excel - 在 VF 页面中导出 Excel - 使用动态图像 URL 时图像未显示

转载 作者:行者123 更新时间:2023-12-04 21:47:04 38 4
gpt4 key购买 nike

我正在将 VF 页面导出为 Excel 文档。当我导出 excel 文件时,图像单元格包含空白数据。下面是我的 VF 页面代码。如果我使用静态 url ( <img alt="Image" src="https://myorgurl/resource/DefaultProfileImage" /> ) 而不是动态图像 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>
<image 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>

我已经尝试在 VF 页面中使用 XML 结构而不是 HTML 标记来解决这个问题,但它不起作用。

最佳答案

仅当“浏览器”成功登录到 Salesforce 时,静态资源才会显示正常。我的意思是想一想,在 https://eu1.salesforce.com/resources/DefaultProfileImage 这样的链接中没有什么全局独一无二的。 . Excel 无法下载图像。在隐私浏览(隐身模式)中转到您的图像的 url,在您登录之前它不会显示 OK。这类似于使用资源或 VF 页面生成带有图像的 PDF 的电子邮件模板。

您需要将图像上传到 Documents(切换到 SF Classic UI),勾选“外部可用图像”复选框,生成的链接将类似于 https://instance.content.force.com/servlet/servlet.ImageServer?id=015...&oid=00D... .这在全局范围内是独一无二的,它包含您的组织 ID 和文档记录的 ID。

您还可以将图像上传到其他地方(Heroku?),在 Salesforce 或社区中创建站点并将其作为公共(public) url 引用......基本上任何使图像可用而无需登录的东西。

关于excel - 在 VF 页面中导出 Excel - 使用动态图像 URL 时图像未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62443929/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com