Macros/Calc/ba025

Summary
This page provides a LibreOffice Basic macro procedure that retrieves the sorting information for a given cell range. It is an example drawn from Chapter 13 ("Calc as a Database") of the 7.0 Calc Guide.

Description
You can use the method createSortDescriptor to retrieve the sorting information for a given cell range. If this method is called on a database range, it will create a sort descriptor using the sorting information stored with that range. On the other hand, if createSortDescriptor is called on a standard named range or an unnamed range, it will generate a sort descriptor with default properties. In either case, the newly-generated sort descriptor can be modified and passed as an argument to a sort method called on a given range.

The macro procedure below demonstrates how to generate and display the sorting information associated with a range. The output of this macro is a dialog box displaying sort descriptor properties.

Code
This [[Media:Retrieve_sorting_information_for_cell_range.ods|Calc spreadsheet]] contains the above LibreOffice Basic code.