4
votes

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
When you right click on the image in excel, is there an option where you can check the path to the image? - user2027202827
I am using embedded image in html, its not a linked image that stays on the external path. Right click on this only has a copy/move/cancel option. Looks like excel recognizes the embedded image but its not able to covert base64 string back to image. So was wondering is there a macro that can be used to achieve this back conversion? - mahbh2001
@mahbh2001, were you ever able to resolve this? - Pyro979

3 Answers

3
votes

An update to the answer by Peter above. It took me another hour or so to figure out how to handle this. Here is an example of how to structure your html file:

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="12345"

--12345
Content-Type: image/jpg;name="logo.jpg"
Content-Transfer-Encoding: base64
Content-ID: <[email protected]>

/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:[email protected]" />
</html>
--12345--

This can be done multiple times for multiple images, just with different names / content-ids. You MUST have the line at the end in order for it to work too.

1
votes

Use mime type will work. This is an example:

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

iVBORw0KGgoAAAANSUhEUgAAAQQAAAEsCAYAAAAl981RAA...
0
votes

give full path in img tag. src='full html path'