Cmdlet
Invoke-OfficeExcelSort
Sorts the used range on the current worksheet.
Syntax
Invoke-OfficeExcelSort
[-Descending]
[-Document <ExcelDocument>]
[-Header] <String>
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]#Parameter set:
HeaderInvoke-OfficeExcelSort
[-Document <ExcelDocument>]
-Order <OrderedDictionary>
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]#Parameter set:
OrderExamples
Sort by one column
Open-OfficeExcel -Path .\Reports\Inventory.xlsx {
ExcelSheet 'Servers' {
ExcelSort Name
}
}Sorts the used range of the Servers sheet by the Name header.
Sort by several columns
Open-OfficeExcel -Path .\Reports\Helpdesk.xlsx {
ExcelSheet 'Tickets' {
ExcelSort -Order ([ordered]@{ Priority = $true; AgeDays = $false })
}
}Sorts tickets by priority ascending and then by age with the oldest first.
Parameters
- -Descending SwitchParameter
- Sort descending (single-column sort).
- -Document ExcelDocument
- Workbook to operate on outside the DSL context.
- -Header String
- Header to sort by (single-column sort).
- -PassThru SwitchParameter
- Emit the worksheet after sorting.
- -Sheet OfficeSheetSelector
- Worksheet name when using Document.
- -Order OrderedDictionary
- Ordered dictionary of header => ascending (true/false).
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.