Migrate to the New Google Sheets

The new version of Google Sheets includes changes to several Apps Script features.

Notable changes

The script gallery is not available in the new version of Sheets. It has been replaced by the add-on store.

Autocomplete for custom functions

The new version of Sheets supports autocomplete for custom functions, much like autocomplete for built-in functions. Custom functions only appear in autocomplete if they are preceded by a JsDoc comment that includes a @customfunction tag, as in the following example:

/**
 * Multiplies the input value by 2.
 *
 * @param {number} input The value to multiply.
 * @customfunction
 */
function double(input) {
  return input * 2;
}

Custom function arguments must be deterministic

Built-in spreadsheet functions that return a different result each time they calculate — such as NOW() or RAND() — are not allowed as arguments to a custom function in the new version of Sheets. If a custom function tries to return a value based on a volatile built-in function, it will display Loading... indefinitely.

Newer syntax for menus, dialogs, and sidebars

The new version of Google Sheets supports the same getUi() syntax used to create menus, dialogs, and sidebars in Google Docs and Forms. Although the Browser class continues to work for both old and new spreadsheets, new Sheets scripts should use the getUi() syntax if possible.

Number and date formats

The number formats used by the new version of Sheets are now compatible with Excel's number format specification. This format has some differences from the old format, especially for date or time values. Specifically:

  • Literal text is surrounded by quotation marks.
  • Both months and minutes are represented by a lowercase m.
  • The AM/PM section is represented as am/pm.

Deprecated methods

The following Spreadsheet methods have been deprecated in the new version of Sheets. To determine information about a file's sharing settings, use the DriveApp methods File.getSharingAccess() and File.getSharingPermission() instead.

发送以下问题的反馈:

此网页
Apps Script
Apps Script