1

I am hoping there is an easy way to do this but am at a loss. It's a hard subject to search on so I apologize if it has been covered previously. couldn't find exactly what I was looking for.

What I have is a MySQL table. In that table there is a field which has a full image src which was scraped from a website like so:

<img src="http://whatever.com/image.jpg" height="30" width="120"/>

Right now I have the entire table being exported into a CSV file which is then opened and manipulated in Excel but it only has this image link in text format.

I am hoping there is an easy way to say save to Excel format xls/xlsx, then reopen the file and it shows the actual image rather than just the text that was pulled from the database.

Thanks much.

Reg
  • 555
  • 5
  • 10
  • 26

1 Answers1

0

Im almost sure you cant have images in CSV, and especially not from a url..

There might be a way to have it in base64 saved in the SQL database although THIS IS NOT ADVISED From there you might be able to configure something to render the image but it would be horribly awkward.

Even at that im 99% certain you cant display the image in CSV.

Edit: just to confirm CSV is text base only. : http://en.wikipedia.org/wiki/Comma-separated_values

You could get Excel to read the image with creating a sub in a worksheet. Paste the code below in.

Dim url_column As Range
Dim image_column As Range

Set url_column = Worksheets(1).UsedRange.Columns("A")
Set image_column = Worksheets(1).UsedRange.Columns("B")

Dim i As Long
For i = 1 To url_column.Cells.Count

  With image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)
    .Left = image_column.Cells(i).Left
    .Top = image_column.Cells(i).Top
    image_column.Cells(i).EntireRow.RowHeight = .Height
  End With

Next

Credit and ref to the EXCEPTIONAL answer : How to get images to appear in Excel given image url

Community
  • 1
  • 1
Pogrindis
  • 7,755
  • 5
  • 31
  • 44
  • I know it can't display the image in the CSV format. I hoping there is code that excel can read from an xls/xlsx file from the URL. – Reg Feb 10 '14 at 19:44