Class SortSpec
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Spécification de Sort
Spécification de tri.
Documentation détaillée
getBackgroundColor()
Renvoie la couleur d'arrière-plan utilisée pour le tri, ou null
si elle est absente.
Renvois
Color
: couleur d'arrière-plan.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDataSourceColumn()
Récupère la colonne de la source de données sur laquelle la spécification de tri agit. Renvoie null
si cette spécification de tri n'agit pas sur une colonne de source de données.
Renvois
DataSourceColumn
: colonne de la source de données sur laquelle la spécification de tri agit.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDimensionIndex()
Renvoie l'index de la dimension ou null
si elle n'est pas associée à un filtre local.
Renvois
Integer
: index de la dimension.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getForegroundColor()
Renvoie la couleur de premier plan utilisée pour le tri, ou null
si elle est absente.
Renvois
Color
: couleur de premier plan.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSortOrder()
Renvoie l'ordre de tri.
Renvois
SortOrder
: ordre de tri.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
isAscending()
Indique si l'ordre de tri est croissant.
Renvois
Boolean
: true
si l'ordre de tri est croissant, ou false
dans le cas contraire.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[null,null,["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003e\u003ccode\u003eSortSpec\u003c/code\u003e defines the specifications for sorting data, such as sort order, colors, and the data source.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to retrieve information about the sort specification, including background and foreground colors, sort order, and the data source column being used.\u003c/p\u003e\n"],["\u003cp\u003eYou can determine if the sort order is ascending using the \u003ccode\u003eisAscending()\u003c/code\u003e method and obtain the dimension index with \u003ccode\u003egetDimensionIndex()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAll methods within \u003ccode\u003eSortSpec\u003c/code\u003e require authorization with specific scopes related to spreadsheet access.\u003c/p\u003e\n"]]],["SortSpec defines the criteria for sorting data. Key actions include retrieving the background and foreground colors used in sorting, if any. It fetches the data source column being sorted, or returns null if not present. It can retrieve the dimension index if linked to a filter. The sort order itself, along with whether the sorting is ascending, can also be obtained using the methods `getSortOrder()` and `isAscending()` respectively.\n"],null,["# Class SortSpec\n\nSortSpec\n\nThe sorting specification. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------|---------------------------------------------------------------------------|------------------------------------------------------------------------|\n| [getBackgroundColor()](#getBackgroundColor()) | [Color](/apps-script/reference/spreadsheet/color) | Returns the background color used for sorting, or `null` if absent. |\n| [getDataSourceColumn()](#getDataSourceColumn()) | [DataSourceColumn](/apps-script/reference/spreadsheet/data-source-column) | Gets the data source column the sort spec acts on. |\n| [getDimensionIndex()](#getDimensionIndex()) | `Integer` | Returns the dimension index or `null` if not linked to a local filter. |\n| [getForegroundColor()](#getForegroundColor()) | [Color](/apps-script/reference/spreadsheet/color) | Returns the foreground color used for sorting, or `null` if absent. |\n| [getSortOrder()](#getSortOrder()) | [SortOrder](/apps-script/reference/spreadsheet/sort-order) | Returns the sort order. |\n| [isAscending()](#isAscending()) | `Boolean` | Returns whether the sort order is ascending. |\n\nDetailed documentation\n----------------------\n\n### `get``Background``Color()`\n\nReturns the background color used for sorting, or `null` if absent.\n\n#### Return\n\n\n[Color](/apps-script/reference/spreadsheet/color) --- The background color.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Data``Source``Column()`\n\nGets the data source column the sort spec acts on. Returns `null` if this sort spec is\nnot acting on a data source column.\n\n#### Return\n\n\n[DataSourceColumn](/apps-script/reference/spreadsheet/data-source-column) --- The data source column the sort spec acts on.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Dimension``Index()`\n\nReturns the dimension index or `null` if not linked to a local filter.\n\n#### Return\n\n\n`Integer` --- The dimension index.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Foreground``Color()`\n\nReturns the foreground color used for sorting, or `null` if absent.\n\n#### Return\n\n\n[Color](/apps-script/reference/spreadsheet/color) --- The foreground color.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Sort``Order()`\n\nReturns the sort order.\n\n#### Return\n\n\n[SortOrder](/apps-script/reference/spreadsheet/sort-order) --- The sort order.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `is``Ascending()`\n\nReturns whether the sort order is ascending.\n\n#### Return\n\n\n`Boolean` --- `true` if the sort order is ascending, or `false` otherwise.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`"]]