API Reference
Cmdlet
Update-OfficeExcelText
Replaces text in worksheet values.
Remarks
Replaces text in worksheet values.
Examples
Replace status text and verify the update count.
PS>
$count = Update-OfficeExcelText -Path .\Report.xlsx -Sheet Summary -OldValue Draft -NewValue Ready
[pscustomobject]@{
Path = '.\Report.xlsx'
Replacements = $count
}
Updates matching text cells on a sheet, saves the workbook, and returns the replacement count.
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
Update-OfficeExcelText [-CaseSensitive] -InputPath <String> -NewValue <String> -OldValue <String> [-Range <String>] [-Regex] [-Sheet <String>] [-SheetIndex <Nullable`1>] [-Show] [<CommonParameters>]#Parameter set:
PathParameters
- CaseSensitive SwitchParameter
- Use case-sensitive matching.
- InputPath String
- Workbook path to update.
- NewValue String
- Replacement text.
- OldValue String
- Text or pattern to replace.
- Range String
- A1 range to update. Defaults to each selected worksheet's used range.
- Regex SwitchParameter
- Treat -OldValue as a regular expression.
- Sheet String
- Worksheet name. Defaults to all sheets for path/document use and current sheet inside an ExcelSheet block.
- SheetIndex Nullable`1
- Worksheet index when using a workbook object or path.
- Show SwitchParameter
- Open the file after saving when using -Path.
Outputs
System.Int32
Update-OfficeExcelText [-CaseSensitive] -Document <ExcelDocument> -NewValue <String> -OldValue <String> [-Range <String>] [-Regex] [-Sheet <String>] [-SheetIndex <Nullable`1>] [<CommonParameters>]#Parameter set:
DocumentParameters
- CaseSensitive SwitchParameter
- Use case-sensitive matching.
- Document ExcelDocument
- Workbook to update outside the DSL context.
- NewValue String
- Replacement text.
- OldValue String
- Text or pattern to replace.
- Range String
- A1 range to update. Defaults to each selected worksheet's used range.
- Regex SwitchParameter
- Treat -OldValue as a regular expression.
- Sheet String
- Worksheet name. Defaults to all sheets for path/document use and current sheet inside an ExcelSheet block.
- SheetIndex Nullable`1
- Worksheet index when using a workbook object or path.
Outputs
System.Int32