Stay organized with collections Save and categorize content based on your preferences.
DrawingRepresents a drawing over a sheet in a spreadsheet.
Detailed documentationgetContainerInfo()
Gets information about where the drawing is positioned in the sheet.
ReturnContainerInfo
— An object containing the drawing's container position.
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
getHeight()
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.
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
getOnAction()
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.
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
getSheet()
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.
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
getWidth()
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.
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
getZIndex()
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.
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
setHeight(height)
Sets the actual height of this drawing in pixels.
Parameters Name Type Descriptionheight
Integer
The desired height in pixels. Return
Drawing
— This drawing, for chaining.
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
setOnAction(macroName)
Assigns a macro function to this drawing.
Parameters Name Type DescriptionmacroName
String
Name of the macro function. Return
Drawing
— This drawing, for chaining.
setPosition(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 DescriptionanchorRowPos
Integer
The drawing's top side is anchored in this row. anchorColPos
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.
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
setWidth(width)
Sets the actual width of this drawing in pixels.
Parameters Name Type Descriptionwidth
Integer
The desired width in pixels. Return
Drawing
— This drawing, for chaining.
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
setZIndex(zIndex)
Sets the z-index of this drawing.
Parameters Name Type DescriptionzIndex
Number
Z-Index of this drawing. Return
Drawing
— This drawing, for chaining.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["A Drawing object represents a drawing element (like a shape or image) placed on a Google Sheet."],["It provides methods to control the drawing's properties such as size, position, and layering order (z-index)."],["You can programmatically add, modify, and remove drawings using Apps Script."],["Drawings can also be assigned to trigger macro functions when clicked."],["Each manipulation of the Drawing object requires specific authorization scopes to be granted to the script."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4