Adds the given user to the list of editors for the Spreadsheet.
Adds the given user to the list of editors for the Spreadsheet. If the user was already on the list of viewers, this method promotes the user out of the list of viewers.
Adds the given user to the list of editors for the Spreadsheet.
Adds the given user to the list of editors for the Spreadsheet. If the user was already on the list of viewers, this method promotes the user out of the list of viewers.
Adds the given array of users to the list of editors for the Spreadsheet.
Adds the given array of users to the list of editors for the Spreadsheet. If any of the users were already on the list of viewers, this method promotes them out of the list of viewers.
Creates a new menu in the Spreadsheet UI.
Creates a new menu in the Spreadsheet UI. Each menu entry runs a user-defined function. Usually, you will want to call it from the onOpen function so that the menu is automatically created when the Spreadsheet is loaded.
Adds the given user to the list of viewers for the Spreadsheet.
Adds the given user to the list of viewers for the Spreadsheet. If the user was already on the list of editors, this method has no effect.
Adds the given user to the list of viewers for the Spreadsheet.
Adds the given user to the list of viewers for the Spreadsheet. If the user was already on the list of editors, this method has no effect.
Adds the given array of users to the list of viewers for the Spreadsheet.
Adds the given array of users to the list of viewers for the Spreadsheet. If any of the users were already on the list of editors, this method has no effect for them.
Appends a row to the spreadsheet.
Appends a row to the spreadsheet. This operation is atomic; it prevents issues where a user asks for the last row, and then writes to that row, and an intervening mutation occurs between getting the last row and writing to it.
Sets the width of the given column to fit its contents
Copies the spreadsheet and returns the new one.
Deletes the currently active sheet.
Deletes the column at the given column position.
Deletes a number of columns starting at the given column position.
Deletes the row at the given row position.
Deletes a number of rows starting at the given row position.
Deletes the specified sheet.
Duplicates the active sheet and makes it the active sheet.
Returns the active cell in this sheet.
Returns the active range for the active sheet.
Returns the active range for the active sheet. Returns the range of cells that is currently considered active. This generally means the range that a user has selected in the active sheet, but in a custom function it refers to the cell being actively recalculated. Note that when called on a SpreadsheetApp it effectively calls getActiveSpreadsheet and then getActiveSheet to act on the active Sheet.
Gets the active sheet in a spreadsheet.
Gets the active sheet in a spreadsheet. The active sheet in a spreadsheet is the sheet that is being displayed in the spreadsheet UI.
Return the data inside this object as a blob converted to the specified content type.
Return the data inside this object as a blob converted to the specified content type. This method adds the appropriate extension to the filename — for example, "myfile.pdf". However, it assumes that the part of the filename that follows the last period (if any) is an existing extension that should be replaced. Consequently, "ChristmasList.12.25.2014" will become "ChristmasList.12.25.pdf".
Return the data inside this object as a blob.
Gets the width in pixels of the given column.
Returns a Range corresponding to the dimensions in which data is present.
Returns a Range corresponding to the dimensions in which data is present. This is functionally equivalent to creating a Range bounded by A1 and (Range.getLastColumn(), Range.getLastRow()).
Gets the list of editors for this Spreadsheet.
Gets the list of editors for this Spreadsheet. If the user who executes the script does not have edit access to the Spreadsheet, this method throws an exception.
Returns the url for the form attached to the spreadsheet, null if there is no form.
Returns the number of frozen columns.
Returns the number of frozen rows.
Gets a unique identifier for this spreadsheet.
Gets a unique identifier for this spreadsheet. A spreadsheet ID can be extracted from its URL. For example, the spreadsheet ID in the URL https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 is "abc1234567".
Returns the position of the last column that has content.
Returns the position of the last row that has content.
Gets the name of the document.
Returns the number of sheets in this spreadsheet.
Returns the owner of the document.
Gets an array of objects representing all protected ranges or sheets in the spreadsheet.
Returns the range as specified in A1 notation or R1C1 notation.
Returns a named range, or null if no range with the given name is found.
Returns a named range, or null if no range with the given name is found. If multiple sheets of the spreadsheet use the same range name, specify the sheet name without additional quotation marks — for example, getRangeByName('TaxRates') or getRangeByName('Sheet Name!TaxRates'), but not getRangeByName('"Sheet Name"!TaxRates').
Gets the height in pixels of the given row.
Returns a sheet with the given name.
Returns a sheet with the given name. If multiple sheets have the same name, the leftmost one is returned. Returns null if there is no sheet with the given name.
Returns the ID of the sheet represented by this object.
Returns the ID of the sheet represented by this object. This is an ID for the sheet that is unique to the spreadsheet. The ID is a monotonically increasing integer assigned at sheet creation time that is independent of sheet position. This is useful in conjunction with methods such as Range.copyFormatToRange(gridId, column, columnEnd, row, rowEnd) that take a gridId parameter rather than a Sheet instance.
Returns the sheet name.
Deprecated.
Deprecated. For spreadsheets created in the newer version of Google Sheets, use Sheet.getProtections(type), which returns the more powerful Protection class. Although this method is deprecated, it will remain available for compatibility with the older version of Sheets
Returns the rectangular grid of values for this range starting at the given coordinates.
Returns the rectangular grid of values for this range starting at the given coordinates. A -1 value given as the row or column position is equivalent to getting the very last row or column that has data in the sheet.
Gets all the sheets in this spreadsheet.
Gets the spreadsheet locale.
Gets the time zone for the spreadsheet.
Returns the url for the given spreadsheet.
Gets the list of viewers and commenters for this Spreadsheet.
Gets the list of viewers and commenters for this Spreadsheet. If the user who executes the script does not have edit access to the Spreadsheet, this method throws an exception.
Hides the columns in the given range.
Hides the rows in the given range.
Inserts a column after the given column position.
Inserts a column before the given column position.
Inserts a number of columns after the given column position.
Inserts a number of columns before the given column position.
Inserts an image in the document at a given row and column, with a pixel offset.
Inserts an image in the document at a given row and column.
Inserts a Blob as an image in the document at a given row and column, with a pixel offset.
Inserts a Blob as an image in the document at a given row and column, with a pixel offset. The image size is retrieved from the blob contents.
Inserts a Blob as an image in the document at a given row and column.
Inserts a Blob as an image in the document at a given row and column. The image size is retrieved from the blob contents.
Inserts a row after the given row position.
Inserts a row before the given row position.
Inserts a number of rows after the given row position.
Inserts a number of rows before the given row position.
Inserts a new sheet in the spreadsheet with the given name and uses optional advanced arguments.
Inserts a new sheet in the spreadsheet with the given name and uses optional advanced arguments. As a side effect, it makes it the active sheet.
Inserts a new sheet in the spreadsheet with the given name at the given index and uses optional advanced arguments.
Inserts a new sheet in the spreadsheet with the given name at the given index and uses optional advanced arguments. As a side effect, it makes it the active sheet.
Inserts a new sheet in the spreadsheet with the given name at the given index.
Inserts a new sheet in the spreadsheet with the given name at the given index. As a side effect, it makes it the active sheet.
Inserts a new sheet in the spreadsheet with the given name.
Inserts a new sheet in the spreadsheet with the given name. As a side effect, it makes it the active sheet.
Inserts a new sheet in the spreadsheet, with a default name and uses optional advanced arguments.
Inserts a new sheet in the spreadsheet, with a default name and uses optional advanced arguments. As a side effect, it makes it the active sheet.
Inserts a new sheet in the spreadsheet at the given index and uses optional advanced arguments.
Inserts a new sheet in the spreadsheet at the given index and uses optional advanced arguments. As a side effect, it makes it the active sheet.
Inserts a new sheet in the spreadsheet at the given index.
Inserts a new sheet in the spreadsheet at the given index. As a side effect, it makes it the active sheet.
Inserts a new sheet in the spreadsheet, with a default name.
Inserts a new sheet in the spreadsheet, with a default name. As a side effect, it makes it the active sheet.
Deprecated.
Deprecated. As of January 2014 this function is deprecated and not available in the new version of Google Sheets.
Deprecated.
Deprecated. As of January 2014 this function is deprecated and not available in the new version of Google Sheets.
Moves the active sheet to the given position in the list of sheets.
Moves the active sheet to the given position in the list of sheets. Throws an exception if the position is negative or greater than the number of sheets.
Removes the given user from the list of editors for the Spreadsheet.
Removes the given user from the list of editors for the Spreadsheet. This method does not block users from accessing the Spreadsheet if they belong to a class of users who have general access — for example, if the Spreadsheet is shared with the user's entire domain.
Removes the given user from the list of editors for the Spreadsheet.
Removes the given user from the list of editors for the Spreadsheet. This method does not block users from accessing the Spreadsheet if they belong to a class of users who have general access — for example, if the Spreadsheet is shared with the user's entire domain.
Removes a menu that was added by addMenu(name, subMenus).
Removes a menu that was added by addMenu(name, subMenus). The name argument should have the same value as the corresponding call to addMenu(name, subMenus).
Deletes a named range with the given name.
Deletes a named range with the given name. Throws an exception if no range with the given name is found in the spreadsheet.
Removes the given user from the list of viewers and commenters for the Spreadsheet.
Removes the given user from the list of viewers and commenters for the Spreadsheet. This method has no effect if the user is an editor, not a viewer. This method also does not block users from accessing the Spreadsheet if they belong to a class of users who have general access — for example, if the Spreadsheet is shared with the user's entire domain.
Removes the given user from the list of viewers and commenters for the Spreadsheet.
Removes the given user from the list of viewers and commenters for the Spreadsheet. This method has no effect if the user is an editor, not a viewer or commenter. This method also does not block users from accessing the Spreadsheet if they belong to a class of users who have general access — for example, if the Spreadsheet is shared with the user's entire domain.
Renames the document.
Renames the current active sheet to the given new name.
Sets the active range for the active sheet.
Sets the active selection, as specified in A1 notation or R1C1 notation.
Sets the active selection region for this sheet.
Sets the given sheet to be the active sheet in the spreadsheet.
Sets the given sheet to be the active sheet in the spreadsheet. The spreadsheet UI will display the chosen sheet unless the sheet belongs to a different spreadsheet.
Deprecated.
Deprecated. As of January 2014 this function is deprecated and not available in the new version of Google Sheets.
Sets the width of the given column in pixels.
Freezes the given number of columns.
Freezes the given number of columns. If zero, no columns are frozen.
Freezes the given number of rows.
Freezes the given number of rows. If zero, no rows are frozen.
Names a range.
Sets the row height of the given row in pixels.
Deprecated.
Deprecated. For spreadsheets created in the newer version of Google Sheets, use Sheet.protect(), which returns the more powerful Protection class. Although this method is deprecated, it will remain available for compatibility with the older version of Sheets
Sets the spreadsheet locale.
Sets the time zone for the spreadsheet.
Displays a custom user interface component in a dialog centered in the user's browser's viewport.
Displays a custom user interface component in a dialog centered in the user's browser's viewport. The server-side script's execution will not be suspended. To communicate with the server side, the user interface component must make asynchronous callbacks to the server-side script.
Sorts a sheet by column.
Sorts a sheet by column. Takes a parameter to specify ascending or descending.
Sorts a sheet by column, ascending.
Shows a popup window in the lower right corner of the spreadsheet with the given title and message, that stays visible for a certain length of time.
Shows a popup window in the lower right corner of the spreadsheet with the given message and title.
Shows a popup window in the lower right corner of the spreadsheet with the given message.
Unhides the column in the given range.
Unhides the row in the given range.
Updates a menu that was added by addMenu(name, subMenus).
Updates a menu that was added by addMenu(name, subMenus). Works exactly like addMenu(name, subMenus).
Spreadsheet This class allows users to access and modify Google Sheets files. Common operations are adding new sheets and adding collaborators.