GetCount
Returns the number of sort fields.
note
This functionality is available in paid ONLYOFFICE Docs editions.
Syntax
expression.GetCount();
expression - A variable that represents a ApiSortFields class.
Parameters
This method doesn't have any parameters.
Returns
number
Example
Count how many sort columns are currently configured for a formatted table in a spreadsheet.
// How do I find out how many sort columns a table has in a spreadsheet?
// Read the total number of active sort columns to verify the table's sort setup in a spreadsheet.
let worksheet = Api.GetActiveSheet();
worksheet.GetRange("A1").SetValue("Product");
worksheet.GetRange("B1").SetValue("Price");
worksheet.GetRange("A2").SetValue("Oranges");
worksheet.GetRange("B2").SetValue(150);
worksheet.GetRange("A3").SetValue("Apples");
worksheet.GetRange("B3").SetValue(100);
let table = worksheet.AddListObject("xlSrcRange", "A1:B3");
let sort = table.GetSort();
let sortFields = sort.GetSortFields();
sortFields.Add(worksheet.GetRange("A1:A3"), "xlSortOnValues", "xlAscending");
worksheet.GetRange("D1").SetValue("Sort fields count:");
worksheet.GetRange("E1").SetValue(sortFields.GetCount());