OfficeIMO

API Reference

Command

Add-OfficeExcelSheet

Namespace PSWriteOffice
Inputs
None
Outputs
System.Object

Adds or reuses a worksheet within the current Excel DSL scope.

Remarks

Adds or reuses a worksheet within the current Excel DSL scope.

Examples

Create a sheet named Data.


PS>New-OfficeExcel -Path .\report.xlsx { Add-OfficeExcelSheet -Name 'Data' { ExcelCell -Address 'A1' -Value 'Region' } }
        

Creates a workbook with a worksheet named Data and writes the header “Region”.

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

Add-OfficeExcelSheet [-Content <ScriptBlock>] [-Name <String>] [-PassThru] [-ValidationMode <Sanitize|Strict>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Parameters

Content ScriptBlock optionalposition: 1pipeline: False
Code to execute inside the worksheet context.
Name String optionalposition: 0pipeline: False
Name of the worksheet to create or reuse. When omitted the last sheet is reused or a default sheet is created.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the ExcelSheet object after execution.
ValidationMode SheetNameValidationMode optionalposition: namedpipeline: Falsevalues: 2
Controls how invalid sheet names are handled.
Possible values: Sanitize, Strict

Outputs

System.Object