Partager via


ExcelScript.RangeSort interface

Gère les opérations de tri sur Range les objets.

Méthode

apply(fields, matchCase, hasHeaders, orientation, method)

Effectue une opération de tri.

Détails de la méthode

apply(fields, matchCase, hasHeaders, orientation, method)

Effectue une opération de tri.

apply(
            fields: SortField[],
            matchCase?: boolean,
            hasHeaders?: boolean,
            orientation?: SortOrientation,
            method?: SortMethod
        ): void;

Paramètres

fields

ExcelScript.SortField[]

Liste des conditions de tri.

matchCase

boolean

Facultatif. Indique si la casse influe sur le classement des chaînes.

hasHeaders

boolean

Facultatif. Indique si la plage comporte un en-tête.

orientation
ExcelScript.SortOrientation

Facultatif. Indique si l’opération trie les lignes ou les colonnes.

method
ExcelScript.SortMethod

Facultatif. Méthode de classement utilisée pour les caractères chinois.

Retourne

void

Exemples

/**
 * This script sorts the used range of the current worksheet.
 */
function main(workbook: ExcelScript.Workbook) {
    // Get the used range of the current worksheet.
    const activeRange = workbook.getActiveWorksheet().getUsedRange();

    // Sort the rows in ascending order based on the last column.
    activeRange.getSort().apply(
        [{
            ascending: true,
            key: activeRange.getColumnCount() - 1
        }],
        false, /* Don't match case. */
        true,  /* Treat the first row as a header row. */
        ExcelScript.SortOrientation.rows
    );
}