Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Edit-OfficeExcelRow

Aliases: Edit-ExcelRow, ExcelRowEdit
Module PSWriteOffice
Aliases
Edit-ExcelRow ExcelRowEdit
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
PSWriteOffice.Services.Excel.ExcelPowerShellRowEdit

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: Path
Edit-OfficeExcelRow -Document <ExcelDocument> [-NumericAsDecimal] [-PassThru] [-Range <String>] [-ScriptBlock] <ScriptBlock> [-Sheet <String>] [-SheetIndex <Int32>] [<CommonParameters>]
#
Parameter set: Document

Examples

Authored help example

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 optional
Prefer decimals instead of doubles for numeric values.
-PassThru SwitchParameter optional
Emit each editable row after the script block runs.
-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path
Workbook path to update.
-Range String optional
A1 range to expose as editable rows. Defaults to the worksheet used range.
-ScriptBlock ScriptBlock requiredposition: 1
Script block to run once per editable row. The row is passed as the first argument.
-Sheet String optionalaliases: WorksheetName
Worksheet name. Defaults to the current sheet inside an ExcelSheet block.
-SheetIndex Int32 optional
Worksheet index when using a workbook object or path.
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
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.