跳到主要内容

SetSortMethod

设置排序方法。

备注

此功能仅在 ONLYOFFICE Docs 付费版本中可用。

语法

expression.SetSortMethod(sortMethod);

expression - 表示 ApiSort 类的变量。

参数

名称必需/可选数据类型默认值描述
sortMethod必需XlSortMethod排序方法。

返回值

此方法不返回任何数据。

示例

选择电子表格中对表格排序时中文字符的排列方式。

// How do I sort Chinese text by pronunciation rather than stroke order in a spreadsheet?

// Switch the ordering rule for Chinese entries between PinYin and stroke-count in a spreadsheet.

let worksheet = Api.GetActiveSheet();
worksheet.GetRange("A1").SetValue("Product");
worksheet.GetRange("A2").SetValue("Apples");
worksheet.GetRange("A3").SetValue("Oranges");
let table = worksheet.AddListObject("xlSrcRange", "A1:A3");

let sort = table.GetSort();
sort.SetSortMethod("xlPinYin");

worksheet.GetRange("C1").SetValue("Sort method:");
worksheet.GetRange("D1").SetValue(sort.GetSortMethod());