The IMAGE function in Excel allows users to display images directly in their spreadsheets by linking to an external source or using a URL. This functionality enhances visual data representation, enabling users to create more engaging reports and presentations.
Syntax
IMAGE(source, [alt_text], [sizing], [link])
- source: This is the URL or path to the image you want to display.
- alt_text: An optional text description of the image for accessibility purposes.
- sizing: An optional parameter that dictates how the image is sized (values can include ‘fit’, ‘fill’, or ‘original’).
- link: An optional parameter that can hold a hyperlink to direct users to another location when they click the image.
Example #1
=IMAGE("https://example.com/image.jpg")
This function retrieves an image from the specified URL and displays it in the cell. For instance, if the URL points to a valid image file, it will be shown in the worksheet. Example output: The image of a product from the specified URL appears in the cell.
Example #2
=IMAGE("https://example.com/image.jpg", "Sample Image")
This version includes alt text for accessibility, describing the image for users who may not be able to see it. Example output: The image is displayed with “Sample Image” as the alternative text when hovering over it.
Example #3
=IMAGE("https://example.com/image.jpg", "Example Image", "fit", "https://example.com")
This function not only shows the image but also resizes it to fit the cell, providing a link that directs to the website when clicked. Example output: The image appears resized to fit the cell, and clicking it redirects to the specified URL.
Error handling
- 404 Not Found: This error occurs when the image source URL is invalid or the image has been removed.
- Invalid URL: If the provided source is not structured correctly, this error indicates that Excel cannot access the image.
- Access Denied: This error appears if the image is hosted on a site that requires permissions or authentication to view.