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());