Cmdlet
Set-OfficeExcelRow
Writes values and applies row layout to a worksheet in a DSL block or through the pipeline.
Syntax
Set-OfficeExcelRow
[-AutoFit]
[-BackgroundColor <OfficeColor>]
[-Bold]
[-ClearHeight]
[-Document <ExcelDocument>]
[-FirstColumn <Object>]
[-Font <String>]
[-Formula]
[-Height <ExcelColumnWidth>]
[-Hidden]
[-Italic]
[-LastColumn <Object>]
[-PassThru]
[-Row] <Int32>
[-Sheet <OfficeSheetSelector>]
[-StartColumn <Object>]
[-Underline]
[[-Values] <Object[]>]
[-WrapText]
[<CommonParameters>]#Parameter set:
DefaultExamples
Write a header row
New-OfficeExcel -Path .\Rota.xlsx {
ExcelSheet 'On call' {
ExcelRow 1 'Week', 'Primary', 'Secondary', 'Escalation' -Bold
}
}Writes column labels across row 1 and makes them bold.
Write a header band under a title
New-OfficeExcel -Path .\Reports\Budget-2027.xlsx {
ExcelSheet 'Departments' {
ExcelCell A1 'Budget 2027 by department'
ExcelRow 3 'Department', 'Q1', 'Q2', 'Q3', 'Q4', 'Total' -Bold -BackgroundColor '#F1F5F9' -Height 22
}
}Writes the quarter labels into row 3 below the sheet title, with a light fill and a taller row so the band stands apart from the data.
Write a totals row with formulas
Open-OfficeExcel -Path .\Finance\Budget-2027.xlsx {
ExcelSheet 'Departments' {
ExcelRow 20 'Total', '=SUM(B4:B19)', '=SUM(C4:C19)', '=SUM(D4:D19)', '=SUM(E4:E19)' -Formula -Bold
}
}Adds a totals row whose cells are formulas; without -Formula the same strings would be stored as text.
Parameters
- -AutoFit SwitchParameter
- Auto-fit row height after writing values and applying style.
- -BackgroundColor OfficeColor
- Apply a background color across the target row span.
- -Bold SwitchParameter
- Apply or clear bold styling across the target row span.
- -ClearHeight SwitchParameter
- Clear any custom row height.
- -Document ExcelDocument
- Workbook to modify. Accepts pipeline input; select its worksheet with Sheet.
- -FirstColumn Object
- First 1-based column affected by style options.
- -Font String
- Apply a font family across the target row span.
- -Formula SwitchParameter
- Interpret explicitly prefixed row strings as formulas.
- -Height ExcelColumnWidth
- Explicit row height in points.
- Hide or unhide the row. Use -Hidden:$false to unhide.
- -Italic SwitchParameter
- Apply or clear italic styling across the target row span.
- -LastColumn Object
- Last 1-based column affected by style options.
- -PassThru SwitchParameter
- Emit the object created or changed by the command.
- -Row Int32
- 1-based row index.
- -Sheet OfficeSheetSelector
- Worksheet name when using Document. The first worksheet is used when no selector is supplied.
- -StartColumn Object
- Starting column index (1-based).
- -Underline SwitchParameter
- Apply or clear underline styling across the target row span.
- -Values Object[]
- Values to write across the row. Numeric, Boolean, and date values retain their native Excel types; strings remain text.
- -WrapText SwitchParameter
- Apply or clear wrap text across the target row span.
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.