API Reference
Command
Invoke-OfficeExcelSort
Sorts the used range on the current worksheet.
Remarks
Sorts the used range on the current worksheet.
Examples
Sort by a single header.
PS>ExcelSheet 'Data' { Invoke-OfficeExcelSort -Header 'Name' }
Sorts by the Name column in ascending order.
Sort by multiple headers in order.
PS>$order = [ordered]@{ Status = $true; Total = $false }\nExcelSheet 'Data' { Invoke-OfficeExcelSort -Order $order }
Sorts by Status ascending, then Total descending.
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.
Syntax
Invoke-OfficeExcelSort [-Descending] -Header <String> [-PassThru] [<CommonParameters>]#Parameter set:
ContextSingleParameters
- Descending SwitchParameter
- Sort descending (single-column sort).
- Header String
- Header to sort by (single-column sort).
- PassThru SwitchParameter
- Emit the worksheet after sorting.
Outputs
System.Object
Invoke-OfficeExcelSort [-Descending] -Document <ExcelDocument> -Header <String> [-PassThru] [-Sheet <String>] [-SheetIndex <Nullable`1>] [<CommonParameters>]#Parameter set:
DocumentSingleParameters
- 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 String
- Worksheet name when using Document.
- SheetIndex Nullable`1
- Worksheet index (0-based) when using Document.
Outputs
System.Object
Invoke-OfficeExcelSort -Document <ExcelDocument> -Order <Hashtable> [-PassThru] [-Sheet <String>] [-SheetIndex <Nullable`1>] [<CommonParameters>]#Parameter set:
DocumentOrderParameters
- Document ExcelDocument
- Workbook to operate on outside the DSL context.
- Order Hashtable
- Ordered dictionary of header => ascending (true/false).
- PassThru SwitchParameter
- Emit the worksheet after sorting.
- Sheet String
- Worksheet name when using Document.
- SheetIndex Nullable`1
- Worksheet index (0-based) when using Document.
Outputs
System.Object
Invoke-OfficeExcelSort -Order <Hashtable> [-PassThru] [<CommonParameters>]#Parameter set:
ContextOrderParameters
- Order Hashtable
- Ordered dictionary of header => ascending (true/false).
- PassThru SwitchParameter
- Emit the worksheet after sorting.
Outputs
System.Object