OfficeIMO

API Reference

Command

Invoke-OfficeExcelSort

Namespace PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Object

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: ContextSingle

Parameters

Descending SwitchParameter optionalposition: namedpipeline: False
Sort descending (single-column sort).
Header String requiredposition: 0pipeline: False
Header to sort by (single-column sort).
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the worksheet after sorting.

Outputs

System.Object

Invoke-OfficeExcelSort [-Descending] -Document <ExcelDocument> -Header <String> [-PassThru] [-Sheet <String>] [-SheetIndex <Nullable`1>] [<CommonParameters>]
#
Parameter set: DocumentSingle

Parameters

Descending SwitchParameter optionalposition: namedpipeline: False
Sort descending (single-column sort).
Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to operate on outside the DSL context.
Header String requiredposition: 0pipeline: False
Header to sort by (single-column sort).
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the worksheet after sorting.
Sheet String optionalposition: namedpipeline: False
Worksheet name when using Document.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
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: DocumentOrder

Parameters

Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to operate on outside the DSL context.
Order Hashtable requiredposition: namedpipeline: False
Ordered dictionary of header => ascending (true/false).
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the worksheet after sorting.
Sheet String optionalposition: namedpipeline: False
Worksheet name when using Document.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Worksheet index (0-based) when using Document.

Outputs

System.Object

Invoke-OfficeExcelSort -Order <Hashtable> [-PassThru] [<CommonParameters>]
#
Parameter set: ContextOrder

Parameters

Order Hashtable requiredposition: namedpipeline: False
Ordered dictionary of header => ascending (true/false).
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the worksheet after sorting.

Outputs

System.Object