Cmdlet
Set-OfficeExcelCell
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:
CoordinatesSet-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:
AddressDescription
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
- Solid background color. Named colors and hexadecimal values are accepted.
- -Column Int32
- 1-based column index.
- -Document ExcelDocument
- Workbook to modify outside a DSL context. Accepts pipeline input.
- -Formula String
- Formula text (without leading =).
- -GradientDegree Double
- Linear gradient angle in degrees.
- -GradientFrom String
- Gradient start color. Named colors and hexadecimal values are accepted.
- -GradientTo String
- Gradient end color. Named colors and hexadecimal values are accepted.
- -NumberFormat String
- Number format code to apply.
- -PassThru SwitchParameter
- Emit the object created or changed by the command.
- -Row Int32
- 1-based row index.
- -Sheet String
- Worksheet name when using Document.
- -SheetIndex Int32
- Worksheet index (0-based) when using Document.
- -Value Object
- Cell value to assign. Numeric, Boolean, and date values retain their native Excel types; strings remain text.
- -Worksheet ExcelSheet
- Worksheet to modify outside a DSL context.
- -Address String
- 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.