Class CellImageBuilder

Cell Image Builder

Builder for Cell Image . This builder creates the image value needed to add an image to a cell.

Properties

Property Type Description
value Type
Value Type The value type of the cell image, which is Value Type.IMAGE .

Methods

Method Return type Brief description
Cell Image Creates the image value type needed to add an image to a cell.
String Returns the alt text description for this image.
String Returns the alt text title for this image.
String Returns a Google-hosted URL to the image.
Cell Image Sets the alt-text description for this image.
Cell Image Sets the alt text title for this image.
Cell Image Builder Sets the image source URL.
Cell Image Builder Creates a cell image builder based on the current image properties.

Detailed documentation

build()

Creates the image value type needed to add an image to a cell. The image value is built from the image properties added to the builder, such as the source URL.

Return

Cell Image — A representation of the image to add to a cell.


get Alt Text Description()

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 following scopes :

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

get Alt Text Title()

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 following scopes :

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

get Content Url()

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 the image might be lost if the spreadsheet's sharing settings change. The returned URL expires after a short period of time.

 const 
  
 range 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (). 
 getRange 
 ( 
 "Sheet1!A1" 
 ); 
 const 
  
 value 
  
 = 
  
 range 
 . 
 getValue 
 (); 
 if 
  
 ( 
 value 
 . 
 valueType 
  
 == 
  
 SpreadsheetApp 
 . 
 ValueType 
 . 
 IMAGE 
 ) 
  
 { 
  
 console 
 . 
 log 
 ( 
 value 
 . 
 getContentUrl 
 ()); 
 } 

Return

String — The Google-hosted URL of the image.


set Alt Text Description(description)

Sets the alt-text description for this image.

Parameters

Name Type Description
description
String The new alt text description for the image.

Return

Cell Image — This image, for chaining.

Authorization

Scripts that use this method require authorization with one or more of the following scopes :

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

set Alt Text Title(title)

Sets the alt text title for this image.

Parameters

Name Type Description
title
String The new alt text title for the image.

Return

Cell Image — This image, for chaining.

Authorization

Scripts that use this method require authorization with one or more of the following scopes :

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

set Source Url(url)

Sets the image source URL.

Parameters

Name Type Description
url
String The URL for the image.

Return

Cell Image Builder — This builder, for chaining.


to Builder()

Creates a cell image builder based on the current image properties. Use set Source Url(url) to set the source URL of the new image. Then you can add it to a cell using Range.setValue(value) or Range.setValues(values) .

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 range 
  
 = 
  
 ss 
 . 
 getRange 
 ( 
 "Sheet1!A1" 
 ); 
 const 
  
 value 
  
 = 
  
 range 
 . 
 getValue 
 (); 
 if 
  
 ( 
 value 
 . 
 valueType 
  
 == 
  
 SpreadsheetApp 
 . 
 ValueType 
 . 
 IMAGE 
 ) 
  
 { 
  
 const 
  
 newImage 
  
 = 
  
 value 
 . 
 toBuilder 
 () 
  
 . 
 setSourceUrl 
 ( 
  
 'https://www.gstatic.com/images/branding/productlogos/apps_script/v10/web-64dp/logo_apps_script_color_1x_web_64dp.png' 
 , 
  
 ) 
  
 . 
 build 
 (); 
  
 const 
  
 newRange 
  
 = 
  
 ss 
 . 
 getRange 
 ( 
 "Sheet1!A2" 
 ); 
  
 newRange 
 . 
 setValue 
 ( 
 newImage 
 ); 
 } 

Return

Cell Image Builder — A builder that creates an image value type based on the given image properties.

Deprecated methods

Create a Mobile Website
View Site in Mobile | Classic
Share by: