Project

PSWriteOffice

PowerShell document automation across Word, Excel, PowerPoint, PDF, Reader, Confluence, Visio, and open text formats.

Stars 159
Forks 14
PowerShell Gallery downloads 158,661
Release v3.0.5
Language: C# Updated: 2026-09-03

API Reference

Cmdlet

Set-OfficeExcelCell

Aliases: ExcelCell
Namespace PSWriteOffice
Aliases
ExcelCell
Inputs
OfficeIMO.Excel.ExcelSheet

Sets a cell value, formula, or number format within the current worksheet.

Remarks

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

Examples

Authored help example

Write values to A1 and B1.

PS>


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.

PS>


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

Uses the worksheet pipeline target without an active DSL scope.

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.

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

Parameters

BackgroundColor String optionalposition: namedpipeline: False
Solid background color. Named colors and hexadecimal values are accepted.
Column Int32 optionalposition: namedpipeline: False
1-based column index.
Document ExcelDocument optionalposition: namedpipeline: False
Workbook to modify outside a DSL context.
Formula String optionalposition: namedpipeline: False
Formula text (without leading =).
GradientDegree Double optionalposition: namedpipeline: False
Linear gradient angle in degrees.
GradientFrom String optionalposition: namedpipeline: False
Gradient start color. Named colors and hexadecimal values are accepted.
GradientTo String optionalposition: namedpipeline: False
Gradient end color. Named colors and hexadecimal values are accepted.
NumberFormat String optionalposition: namedpipeline: False
Number format code to apply.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the object created or changed by the command.
Row Int32 optionalposition: namedpipeline: False
1-based row index.
Sheet String optionalposition: namedpipeline: False
Worksheet name when using Document.
SheetIndex Int32 optionalposition: namedpipeline: False
Worksheet index (0-based) when using Document.
Value Object optionalposition: namedpipeline: False
Cell value to assign.
Worksheet ExcelSheet optionalposition: namedpipeline: True (ByValue)aliases: SheetObject
Worksheet to modify outside a DSL context.
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

Parameters

Address String optionalposition: namedpipeline: False
A1-style cell address (e.g., A1, C5).
BackgroundColor String optionalposition: namedpipeline: False
Solid background color. Named colors and hexadecimal values are accepted.
Document ExcelDocument optionalposition: namedpipeline: False
Workbook to modify outside a DSL context.
Formula String optionalposition: namedpipeline: False
Formula text (without leading =).
GradientDegree Double optionalposition: namedpipeline: False
Linear gradient angle in degrees.
GradientFrom String optionalposition: namedpipeline: False
Gradient start color. Named colors and hexadecimal values are accepted.
GradientTo String optionalposition: namedpipeline: False
Gradient end color. Named colors and hexadecimal values are accepted.
NumberFormat String optionalposition: namedpipeline: False
Number format code to apply.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the object created or changed by the command.
Sheet String optionalposition: namedpipeline: False
Worksheet name when using Document.
SheetIndex Int32 optionalposition: namedpipeline: False
Worksheet index (0-based) when using Document.
Value Object optionalposition: namedpipeline: False
Cell value to assign.
Worksheet ExcelSheet optionalposition: namedpipeline: True (ByValue)aliases: SheetObject
Worksheet to modify outside a DSL context.