Cmdlet
Edit-OfficeExcelRow
Runs a script block against editable worksheet rows.
Syntax
Edit-OfficeExcelRow [-NumericAsDecimal] [-PassThru] [-Path] <String> [-Range <String>] [-ScriptBlock] <ScriptBlock> [-Sheet <String>] [-SheetIndex <Int32>] [<CommonParameters>]#Parameter set:
PathEdit-OfficeExcelRow -Document <ExcelDocument> [-NumericAsDecimal] [-PassThru] [-Range <String>] [-ScriptBlock] <ScriptBlock> [-Sheet <String>] [-SheetIndex <Int32>] [<CommonParameters>]#Parameter set:
DocumentExamples
Edit rows by header name.
Edit-OfficeExcelRow -Path .\Report.xlsx -Sheet Data -ScriptBlock { param($row) if ($row.Get[string]('Status') -eq 'Draft') { $row.Set('Status', 'Ready') } }Loads editable row handles, lets the script update cells, and saves the workbook.
Parameters
- -NumericAsDecimal SwitchParameter
- Prefer decimals instead of doubles for numeric values.
- -PassThru SwitchParameter
- Emit each editable row after the script block runs.
- -Path String
- Workbook path to update.
- -Range String
- A1 range to expose as editable rows. Defaults to the worksheet used range.
- -ScriptBlock ScriptBlock
- Script block to run once per editable row. The row is passed as the first argument.
- -Sheet String
- Worksheet name. Defaults to the current sheet inside an ExcelSheet block.
- -SheetIndex Int32
- Worksheet index when using a workbook object or path.
- -Document ExcelDocument
- Workbook to update outside the DSL context.
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.
Outputs
PSWriteOffice.Services.Excel.ExcelPowerShellRowEdit: Header-aware editable worksheet row used by Edit-OfficeExcelRow.