Retrieve image to Excel from the Internet
=IMAGE(source, [alt_text], [sizing], [height], [width])
| Parameter | Description |
|---|---|
source |
Path to image as a URL. |
alt_text |
[optional] Text to describe the image for accessibility. |
sizing |
[optional] 0 = Fit to cell, 1 = Fill cell, 2 = Original size, 3 = Custom size. |
height |
[optional] Height of the image in pixels. |
width |
[optional] Width of the image in pixels. |
In its simplest form, the IMAGE function requires just the path to an image:
=IMAGE(source)
For example, to retrieve an image of the Norwegian flag (which exists on this website as the file "flag_norway.png", you can use the IMAGE function li
=IMAGE("https://exceljet.net/sites/default/files/flag_norway.png")
IMAGE returns an image directly to a cell. In the worksheet below, you can see an example of using the IMAGE function to return six different country
=IMAGE(C5)
Because IMAGE accepts a path to an image as plain text, this text can be created programmatically with another formula. This is useful when the path t
flag_canada.png
flag_united_states.png
flag_germany.png
flag_united_kingdom.png
flag_mexico.png
flag_france.png
In addition, the path always begins with the same text:
"https://exceljet.net/sites/default/files/"
Because we already have the country names in column B, and because the flag images are consistently named, we have what we need to assemble each image
=SUBSTITUTE("https://exceljet.net/sites/default/files/flag_xxxx.png",
"xxxx",SUBSTITUTE(LOWER(B5)," ","_"))