Cmdlet
Set-OfficeExcelAutoFilter
Adds an AutoFilter to a range and applies filter conditions.
Syntax
Set-OfficeExcelAutoFilter
[-Criteria <Hashtable>]
[-Document <ExcelDocument>]
[-PassThru]
[-Range] <String>
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]#Parameter set:
RangeSet-OfficeExcelAutoFilter
[-Between <Double[]>]
[-Contains <String>]
[-Document <ExcelDocument>]
[-DoesNotContain <String>]
[-EndsWith <String>]
[-GreaterThanOrEqual <Double>]
[-Header] <String>
[-LessThanOrEqual <Double>]
[-NotBetween <Double[]>]
[-NotEqual <Double>]
[-PassThru]
[-Range <String>]
[-Sheet <OfficeSheetSelector>]
[-StartsWith <String>]
[-Value <String[]>]
[<CommonParameters>]#Parameter set:
ConditionExamples
Add filter buttons to a range
Open-OfficeExcel -Path .\Reports\Inventory.xlsx {
ExcelSheet 'Servers' {
ExcelAutoFilter A1:F500
}
}Adds AutoFilter drop-downs to the header row of A1:F500.
Open a sheet filtered to the open work
Open-OfficeExcel -Path .\Reports\Helpdesk.xlsx {
ExcelSheet 'Tickets' {
ExcelAutoFilter -Header Status -Value 'Open', 'On hold'
ExcelAutoFilter -Header AgeDays -GreaterThanOrEqual 3
}
}Filters the ticket list to the Open and On hold statuses with at least three days of age, so the sheet opens on the work that needs attention.
Filter a new range by header names
Open-OfficeExcel -Path .\Reports\Helpdesk.xlsx {
ExcelSheet 'Tickets' {
ExcelAutoFilter A1:H900 -Criteria @{ Status = 'Open', 'On hold'; Region = 'EMEA' }
}
}Adds filter buttons and immediately shows only open EMEA tickets.
Parameters
- -Criteria Hashtable
- Maps header names to filter values, value lists or comparison criteria.
- -Document ExcelDocument
- Caller-owned workbook; omission uses the enclosing Excel content block.
- -PassThru SwitchParameter
- Emits the native result after the operation.
- -Range String
- A1 cell range on the selected worksheet.
- -Sheet OfficeSheetSelector
- Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
- -Between Double[]
- Inclusive numeric range condition. Provide exactly two values: minimum, maximum.
- -Contains String
- Text that the column value must contain.
- -DoesNotContain String
- Text that the column value must not contain.
- -EndsWith String
- Text that the column value must end with.
- -GreaterThanOrEqual Double
- Numeric greater-than-or-equal condition.
- -Header String
- Header text identifying the target column.
- -LessThanOrEqual Double
- Numeric less-than-or-equal condition.
- -NotBetween Double[]
- Outside numeric range condition. Provide exactly two values: minimum, maximum.
- -NotEqual Double
- Numeric not-equal condition.
- -StartsWith String
- Text that the column value must start with.
- -Value String[]
- Value or values consumed by the selected operation.
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.