Share via


ExcelScript.RangeSort interface

Administra las operaciones de ordenación en Range objetos.

Métodos

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

Realizar una operación de ordenación.

Detalles del método

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

Realizar una operación de ordenación.

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

Parámetros

fields

ExcelScript.SortField[]

La lista de condiciones por las que realizar la ordenación.

matchCase

boolean

Opcional. Indica si la ordenación de cadenas distingue mayúsculas de minúsculas.

hasHeaders

boolean

Opcional. Si el rango tiene un encabezado.

orientation
ExcelScript.SortOrientation

Opcional. Indica si la operación ordena filas o columnas.

method
ExcelScript.SortMethod

Opcional. Método de ordenación que se usa para los caracteres chinos.

Devoluciones

void

Ejemplos

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