Class Drawing

Drawing

Represents a drawing over a sheet in a spreadsheet.

Methods

Method Return type Brief description
Container Info Gets information about where the drawing is positioned in the sheet.
Integer Returns the actual height of this drawing in pixels.
String Returns the name of the macro attached to this drawing.
Sheet Returns the sheet this drawing appears on.
Integer Returns the actual width of this drawing in pixels.
Number Returns the z-index of this drawing.
void Deletes this drawing from the spreadsheet.
Drawing Sets the actual height of this drawing in pixels.
Drawing Assigns a macro function to this drawing.
Drawing Sets the position where the drawing appears on the sheet.
Drawing Sets the actual width of this drawing in pixels.
Drawing Sets the z-index of this drawing.

Detailed documentation

get Container Info()

Gets information about where the drawing is positioned in the sheet.

Return

Container Info — An object containing the drawing's container position.

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 Height()

Returns the actual height of this drawing in pixels.

 // Logs the height of all drawings in a sheet 
 const 
  
 drawings 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSheet 
 (). 
 getDrawings 
 (); 
 for 
  
 ( 
 let 
  
 i 
  
 = 
  
 0 
 ; 
  
 i 
 < 
 drawings 
 . 
 length 
 ; 
  
 i 
 ++ 
 ) 
  
 { 
  
 Logger 
 . 
 log 
 ( 
 drawings 
 [ 
 i 
 ]. 
 getHeight 
 ()); 
 } 

Return

Integer — The height of the drawing in pixels.

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 On Action()

Returns the name of the macro attached to this drawing.

 // Logs the macro name of all drawings on the active sheet. 
 const 
  
 drawings 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSheet 
 (). 
 getDrawings 
 (); 
 for 
  
 ( 
 let 
  
 i 
  
 = 
  
 0 
 ; 
  
 i 
 < 
 drawings 
 . 
 length 
 ; 
  
 i 
 ++ 
 ) 
  
 { 
  
 Logger 
 . 
 log 
 ( 
 drawings 
 [ 
 i 
 ]. 
 getOnAction 
 ()); 
 } 

Return

String — The macro name attached to this drawing.

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 Sheet()

Returns the sheet this drawing appears on.

 // Logs the parent sheet of all drawings on the active sheet. 
 const 
  
 drawings 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSheet 
 (). 
 getDrawings 
 (); 
 for 
  
 ( 
 let 
  
 i 
  
 = 
  
 0 
 ; 
  
 i 
 < 
 drawings 
 . 
 length 
 ; 
  
 i 
 ++ 
 ) 
  
 { 
  
 Logger 
 . 
 log 
 ( 
 drawings 
 [ 
 i 
 ]. 
 getSheet 
 ()); 
 } 

Return

Sheet — The sheet the drawing appears on.

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 Width()

Returns the actual width of this drawing in pixels.

 // Logs the width of all drawings in a sheet 
 const 
  
 drawings 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSheet 
 (). 
 getDrawings 
 (); 
 for 
  
 ( 
 let 
  
 i 
  
 = 
  
 0 
 ; 
  
 i 
 < 
 drawings 
 . 
 length 
 ; 
  
 i 
 ++ 
 ) 
  
 { 
  
 Logger 
 . 
 log 
 ( 
 drawings 
 [ 
 i 
 ]. 
 getWidth 
 ()); 
 } 

Return

Integer — The width of the drawing in pixels.

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 ZIndex()

Returns the z-index of this drawing.

 // Logs the z-index of all drawings on the active sheet. 
 const 
  
 drawings 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSheet 
 (). 
 getDrawings 
 (); 
 for 
  
 ( 
 let 
  
 i 
  
 = 
  
 0 
 ; 
  
 i 
 < 
 drawings 
 . 
 length 
 ; 
  
 i 
 ++ 
 ) 
  
 { 
  
 Logger 
 . 
 log 
 ( 
 drawings 
 [ 
 i 
 ]. 
 getZIndex 
 ()); 
 } 

Return

Number — Z-Index of this drawing.

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

remove()

Deletes this drawing from the spreadsheet. Any further operation on the drawing results in a script error.

 // Deletes all drawings from the active sheet. 
 const 
  
 drawings 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSheet 
 (). 
 getDrawings 
 (); 
 for 
  
 ( 
 let 
  
 i 
  
 = 
  
 0 
 ; 
  
 i 
 < 
 drawings 
 . 
 length 
 ; 
  
 i 
 ++ 
 ) 
  
 { 
  
 drawings 
 [ 
 i 
 ]. 
 remove 
 (); 
 } 

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 Height(height)

Sets the actual height of this drawing in pixels.

Parameters

Name Type Description
height
Integer The desired height in pixels.

Return

Drawing — This drawing, 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 On Action(macroName)

Assigns a macro function to this drawing.

Parameters

Name Type Description
macro Name
String Name of the macro function.

Return

Drawing — This drawing, for chaining.


set Position(anchorRowPos, anchorColPos, offsetX, offsetY)

Sets the position where the drawing appears on the sheet. The anchor row and column position indices are 1-indexed.

Parameters

Name Type Description
anchor Row Pos
Integer The drawing's top side is anchored in this row.
anchor Col Pos
Integer The drawing's top side is anchored in this col.
offsetX
Integer The horizontal offset from the cell corner in pixels.
offsetY
Integer The vertical offset from the cell corner in pixels.

Return

Drawing — This drawing, 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 Width(width)

Sets the actual width of this drawing in pixels.

Parameters

Name Type Description
width
Integer The desired width in pixels.

Return

Drawing — This drawing, 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 ZIndex(zIndex)

Sets the z-index of this drawing.

Parameters

Name Type Description
zIndex
Number Z-Index of this drawing.

Return

Drawing — This drawing, for chaining.

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