ExcelScript.RangeSort interface

オブジェクトの並べ替え操作を Range 管理します。

メソッド

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

並べ替え操作を実行します。

メソッドの詳細

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

並べ替え操作を実行します。

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

パラメーター

fields

ExcelScript.SortField[]

並べ替えに使用する条件の一覧。

matchCase

boolean

オプション。 大文字小文字の区別が文字列の順序に影響を与えるかどうか。

hasHeaders

boolean

オプション。 範囲にヘッダーがあるかどうか。

orientation
ExcelScript.SortOrientation

オプション。 操作が行と列のどちらの並べ替えかを示します。

method
ExcelScript.SortMethod

オプション。 中国語文字に使用される順序付けの方法です。

戻り値

void

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