Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Set-OfficeExcelCell

Aliases: ExcelCell
Module
PSWriteOffice
Aliases
ExcelCell
Inputs
OfficeIMO.Excel.ExcelDocument OfficeIMO.Excel.ExcelSheet

Sets a cell value, formula, number format, or fill.

Syntax

Set-OfficeExcelCell
[-BackgroundColor <String>]
[-Column <Int32>]
[-Document <ExcelDocument>]
[-Formula <String>]
[-GradientDegree <Double>]
[-GradientFrom <String>]
[-GradientTo <String>]
[-NumberFormat <String>]
[-PassThru]
[-Row <Int32>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-Value <Object>]
[-Worksheet <ExcelSheet>]
[<CommonParameters>]
#
Parameter set: Coordinates
Set-OfficeExcelCell
[-Address <String>]
[-BackgroundColor <String>]
[-Document <ExcelDocument>]
[-Formula <String>]
[-GradientDegree <Double>]
[-GradientFrom <String>]
[-GradientTo <String>]
[-NumberFormat <String>]
[-PassThru]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-Value <Object>]
[-Worksheet <ExcelSheet>]
[<CommonParameters>]
#
Parameter set: Address

Description

Supports A1 addresses or row/column coordinates for DSL-style composition.

Examples

Write values to A1 and B1.

ExcelSheet 'Data' { Set-OfficeExcelCell -Address 'A1' -Value 'Region'; Set-OfficeExcelCell -Row 1 -Column 2 -Value 'Revenue' }

Writes two headers in the first row.

Write to an explicit worksheet.

$sheet | Set-OfficeExcelCell -Address B2 -Value 42 -NumberFormat '#,##0'

Uses the worksheet pipeline target without an active DSL scope.

Parameters

-BackgroundColor String optional
Solid background color. Named colors and hexadecimal values are accepted.
-Column Int32 optionalsets: Coordinates
1-based column index.
-Document ExcelDocument optionalpipeline: True (ByValue)
Workbook to modify outside a DSL context. Accepts pipeline input.
-Formula String optional
Formula text (without leading =).
-GradientDegree Double optional
Linear gradient angle in degrees.
-GradientFrom String optional
Gradient start color. Named colors and hexadecimal values are accepted.
-GradientTo String optional
Gradient end color. Named colors and hexadecimal values are accepted.
-NumberFormat String optional
Number format code to apply.
-PassThru SwitchParameter optional
Emit the object created or changed by the command.
-Row Int32 optionalsets: Coordinates
1-based row index.
-Sheet String optional
Worksheet name when using Document.
-SheetIndex Int32 optional
Worksheet index (0-based) when using Document.
-Value Object optional
Cell value to assign. Numeric, Boolean, and date values retain their native Excel types; strings remain text.
-Worksheet ExcelSheet optionalpipeline: True (ByValue)aliases: SheetObject
Worksheet to modify outside a DSL context.
-Address String optionalsets: Address
A1-style cell address (e.g., A1, C5).

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.