html to excel convert with embeded image

时间:2016-06-18 20:21:58

标签: html excel image vba

I have got my html file with html table with the embedded image using tag [ img src="data:image/png;base64, ] . I would like to convert it to excel with image columns showing the actual image. When I open this html file in excel , the table is shown fine but the image is shown with red cross place holder as shownExcel import with embedded image

Is there any way to convert this base64 encoded image to be displayed in excel cells ?

regards

3 个答案:

答案 0 :(得分:2)

上述彼得对答案的更新。我花了大约一个小时才弄清楚如何处理。这是一个如何构造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--

对于多个图像,可以使用不同的名称/ content-id多次执行此操作。为了使它也能正常工作,您必须在末尾有一行。

答案 1 :(得分:1)

使用mime类型将有效。 这是一个例子:

------BOUNDARY_1502961982957--
Content-Location: file:///tmp/1502961982957/main.files/1502961983076.png
Content-Transfer-Encoding: base64
Content-Type: image/png

iVBORw0KGgoAAAANSUhEUgAAAQQAAAEsCAYAAAAl981RAA...

答案 2 :(得分:0)

在 img 标签中给出完整路径。 src='完整的 html 路径'