Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeExcelRow

Aliases: ExcelRow
Module
PSWriteOffice
Aliases
ExcelRow
Inputs
OfficeIMO.Excel.ExcelDocument

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: Default

Examples

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 optional
Auto-fit row height after writing values and applying style.
-BackgroundColor OfficeColor optional
Apply a background color across the target row span.
-Bold SwitchParameter optional
Apply or clear bold styling across the target row span.
-ClearHeight SwitchParameter optional
Clear any custom row height.
-Document ExcelDocument optionalpipeline: True (ByValue)
Workbook to modify. Accepts pipeline input; select its worksheet with Sheet.
-FirstColumn Object optional
First 1-based column affected by style options.
-Font String optional
Apply a font family across the target row span.
-Formula SwitchParameter optional
Interpret explicitly prefixed row strings as formulas.
-Height ExcelColumnWidth optional
Explicit row height in points.
-Hidden SwitchParameter optional
Hide or unhide the row. Use -Hidden:$false to unhide.
-Italic SwitchParameter optional
Apply or clear italic styling across the target row span.
-LastColumn Object optional
Last 1-based column affected by style options.
-PassThru SwitchParameter optional
Emit the object created or changed by the command.
-Row Int32 requiredposition: 0
1-based row index.
-Sheet OfficeSheetSelector optional
Worksheet name when using Document. The first worksheet is used when no selector is supplied.
-StartColumn Object optional
Starting column index (1-based).
-Underline SwitchParameter optional
Apply or clear underline styling across the target row span.
-Values Object[] optionalposition: 1
Values to write across the row. Numeric, Boolean, and date values retain their native Excel types; strings remain text.
-WrapText SwitchParameter optional
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.