我有我的 html 文件,其中包含 html 表格和使用标签的嵌入图像 [ img src="data:image/png;base64, ] 。我想将其转换为 excel,图像列显示实际图像。当我在 excel 中打开此 html 文件时,表格显示正常,但图像显示如图所示带有红十字占位符
有没有办法将这个 base64 编码的图像转换为在 excel 单元格中显示?
问候
最佳答案
更新了上面 Peter 的回答。我又花了一个小时左右的时间才弄清楚如何处理这个问题。以下是如何构建 html 文件的示例:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="12345"
--12345
Content-Type: image/jpg;name="logo.jpg"
Content-Transfer-Encoding: base64
Content-ID: <logo.jpg@site.com>
/9j/4QAYRXhpZgAASUkqAAgAAAAAAAA...
--12345
Content-Type: text/html; charset="utf-8"
<html>
<!-- Your HTML -->
<!-- Somewhere in the HTML, replace your images with this, matching the content-id you created above -->
<img width="your width" height="your height" src="cid:logo.jpg@site.com" />
</html>
--12345--
这可以对多个图像进行多次,只是使用不同的名称/内容 ID。您必须在末尾添加该行才能使其正常工作。
关于html 到 excel 转换为嵌入图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37901299/