Cmdlet
Invoke-OfficeExcelSort
Sorts the used range on the current worksheet.
Syntax
Invoke-OfficeExcelSort
[-Descending]
[-Header] <String>
[-PassThru]
[<CommonParameters>]#Parameter set:
ContextSingleInvoke-OfficeExcelSort
[-Descending]
-Document <ExcelDocument>
[-Header] <String>
[-PassThru]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]#Parameter set:
DocumentSingleInvoke-OfficeExcelSort
-Document <ExcelDocument>
-Order <Hashtable>
[-PassThru]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]#Parameter set:
DocumentOrderInvoke-OfficeExcelSort
-Order <Hashtable>
[-PassThru]
[<CommonParameters>]#Parameter set:
ContextOrderExamples
Sort by a single header.
ExcelSheet 'Data' { Invoke-OfficeExcelSort -Header 'Name' }Sorts by the Name column in ascending order.
Sort by multiple headers in order.
$order = [ordered]@{ Status = $true; Total = $false }\nExcelSheet 'Data' { Invoke-OfficeExcelSort -Order $order }Sorts by Status ascending, then Total descending.
Parameters
- -Descending SwitchParameter
- Sort descending (single-column sort).
- -Header String
- Header to sort by (single-column sort).
- -PassThru SwitchParameter
- Emit the worksheet after sorting.
- -Document ExcelDocument
- Workbook to operate on outside the DSL context.
- -Sheet String
- Worksheet name when using Document.
- -SheetIndex Int32
- Worksheet index (0-based) when using Document.
- -Order Hashtable
- 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.