Class CellImage Stay organized with collections Save and categorize content based on your preferences.
Page Summary
CellImage represents an image value in a cell and is added using
SpreadsheetApp.newCellImage()andCellImageBuilder.CellImage has a
valueTypeproperty which is alwaysValueType.IMAGE.Key methods include retrieving alt text (
getAltTextDescription,getAltTextTitle), getting a Google-hosted content URL (getContentUrl), and creating a builder based on current properties (toBuilder).The
getUrl()method is deprecated as the source URL is often unavailable for newly inserted images.
Represents an image value in a cell. To add an image to a cell, you must create a new image valuefor the image usingSpreadsheet andCell. Then you can useRange.setValue(value) orRange.setValues(values) toadd the image value to the cell.
Properties
| Property | Type | Description |
|---|---|---|
value | Value | The value type of the cell image, which isValue. |
Methods
| Method | Return type | Brief description |
|---|---|---|
get | String | Returns the alt text description for this image. |
get | String | Returns the alt text title for this image. |
get | String | Returns a Google-hosted URL to the image. |
to | Cell | Creates a cell image builder based on the current image properties. |
Deprecated methods
| Method | Return type | Brief description |
|---|---|---|
| String | Gets the image's source URL. |
Detailed documentation
getAltTextDescription()
Returns the alt text description for this image.
Return
String — The alt text description.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
getAltTextTitle()
Returns the alt text title for this image.
Return
String — The alt text title.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
getContentUrl()
Returns a Google-hosted URL to the image. This URL is tagged with the account of the requester,so anyone with the URL effectively accesses the image as the original requester. Access to theimage might be lost if the spreadsheet's sharing settings change. The returned URL expiresafter a short period of time.
constrange=SpreadsheetApp.getActiveSpreadsheet().getRange("Sheet1!A1");constvalue=range.getValue();if(value.valueType==SpreadsheetApp.ValueType.IMAGE){console.log(value.getContentUrl());}
Return
String — The Google-hosted URL of the image.
toBuilder()
Creates a cell image builder based on the current image properties. UseCell to set the source URL of the new image. Then you can add it to acell usingRange.setValue(value) orRange.setValues(values).
constss=SpreadsheetApp.getActiveSpreadsheet();constrange=ss.getRange("Sheet1!A1");constvalue=range.getValue();if(value.valueType==SpreadsheetApp.ValueType.IMAGE){constnewImage=value.toBuilder().setSourceUrl('https://www.gstatic.com/images/branding/productlogos/apps_script/v10/web-64dp/logo_apps_script_color_1x_web_64dp.png',).build();constnewRange=ss.getRange("Sheet1!A2");newRange.setValue(newImage);}
Return
Cell — A builder that creates an image value type based on the given image properties.
Deprecated methods
getUrl()
getUrl() Deprecated. For most newly inserted images, the source URL is unavailable.
Gets the image's source URL. Returns an empty string if the URL is unavailable. For most newlyinserted images, the source URL is unavailable regardless how the image is inserted.
Return
String — The image's source URL if available; returns an empty string otherwise.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.