ExcelScript.RangeSort interface

Verwaltet Sortiervorgänge für Range Objekte.

Methoden

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

Führt einen Sortiervorgang aus.

Details zur Methode

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

Führt einen Sortiervorgang aus.

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

Parameter

fields

ExcelScript.SortField[]

Die Liste der Bedingungen, nach denen sortiert werden soll.

matchCase

boolean

Optional. Gibt an, ob sich die Groß-/Kleinschreibung auf die Zeichenfolgensortierung auswirkt.

hasHeaders

boolean

Optional. Gibt an, ob der Bereich eine Kopfzeile aufweist.

orientation
ExcelScript.SortOrientation

Optional. Gibt an, ob der Vorgang Zeilen oder Spalten sortiert.

method
ExcelScript.SortMethod

Optional. Die Sortiermethode für chinesische Zeichen.

Gibt zurück

void

Beispiele

/**
 * 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
    );
}