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

New-OfficeExcel

Aliases: ExcelNew, OfficeExcel
Namespace PSWriteOffice
Aliases
ExcelNew OfficeExcel
Inputs
None

Creates a new Excel workbook using the DSL.

Remarks

Runs the provided script block inside an ExcelSheet/ExcelCell DSL context and saves the file.

Examples

Authored help example

Create a workbook with a sheet and a few cells.

PS>


New-OfficeExcel -Path .\report.xlsx { ExcelSheet 'Data' { ExcelCell -Address 'A1' -Value 'Region' } }
        

Creates report.xlsx and writes “Region” into cell A1 on the Data worksheet.

Keep a workbook for incremental composition.

PS>


$workbook = New-OfficeExcel -Path .\report.xlsx -NoSave
            $sheet = $workbook | Add-OfficeExcelSheet -Name 'Data' -PassThru
            $sheet | Set-OfficeExcelCell -Address A1 -Value 'Region'
            $workbook | Save-OfficeExcel
            $workbook | Close-OfficeExcel
        

Associates the output path with a live workbook, changes a worksheet, then saves and closes it once.

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

New-OfficeExcel [-ApplicationName <String>] [-Author <String>] [-Category <String>] [-ClearCachedFormulaResults] [-Company <String>] [-Content <ScriptBlock>] [-DateSystem <1900|1904|NineteenHundred|NineteenFour>] [-Description <String>] [-DisableFastPackageWriter] [-DocumentTitle <String>] [-EvaluateFormulas] [-ForceFullCalculationOnOpen] [-Keywords <String>] [-LastModifiedBy <String>] [-Manager <String>] [-MarkFormulasDirty] [-NoSave] [-Open] [-PassThru] [-Password <String>] -Path <String> [-SafePreflight] [-SafeRepairDefinedNames] [-Subject <String>] [-TemplatePath <String>] [-ValidateOpenXml] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Parameters

ApplicationName String optionalposition: namedpipeline: False
Workbook application-name metadata.
Author String optionalposition: namedpipeline: False
Workbook author metadata.
Category String optionalposition: namedpipeline: False
Workbook category metadata.
ClearCachedFormulaResults SwitchParameter optionalposition: namedpipeline: False
Remove cached formula results before saving.
Company String optionalposition: namedpipeline: False
Workbook company metadata.
Content ScriptBlock optionalposition: 1pipeline: False
DSL scriptblock describing workbook content.
DateSystem String optionalposition: namedpipeline: Falsevalues: 4
Workbook date system for Excel date serials.
Possible values: 1900, 1904, NineteenHundred, NineteenFour
Description String optionalposition: namedpipeline: False
Workbook description metadata.
DisableFastPackageWriter SwitchParameter optionalposition: namedpipeline: False
Disable OfficeIMO fast package writers for this save.
DocumentTitle String optionalposition: namedpipeline: False
Workbook document title metadata.
EvaluateFormulas SwitchParameter optionalposition: namedpipeline: False
Evaluate supported formulas and write cached values before saving.
ForceFullCalculationOnOpen SwitchParameter optionalposition: namedpipeline: False
Request a full workbook recalculation when opened in Excel-compatible applications.
Keywords String optionalposition: namedpipeline: False
Workbook keyword metadata.
LastModifiedBy String optionalposition: namedpipeline: False
Workbook last-modified-by metadata.
Manager String optionalposition: namedpipeline: False
Workbook manager metadata.
MarkFormulasDirty SwitchParameter optionalposition: namedpipeline: False
Mark formula cells dirty before saving.
NoSave SwitchParameter optionalposition: namedpipeline: False
Skip saving the workbook after running the DSL.
Open SwitchParameter optionalposition: namedpipeline: False
Open the workbook in Excel after saving.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit a FileInfo for convenience.
Password String optionalposition: namedpipeline: False
Password used to save the workbook as an encrypted package.
Path String requiredposition: 0pipeline: Falsealiases: FilePath
Destination path for the workbook.
SafePreflight SwitchParameter optionalposition: namedpipeline: False
Run OfficeIMO worksheet preflight cleanup before saving.
SafeRepairDefinedNames SwitchParameter optionalposition: namedpipeline: False
Repair common defined-name issues before saving.
Subject String optionalposition: namedpipeline: False
Workbook subject metadata.
TemplatePath String optionalposition: namedpipeline: Falsealiases: Template
Optional workbook template package copied before running the DSL.
ValidateOpenXml SwitchParameter optionalposition: namedpipeline: False
Validate the saved package with OpenXmlValidator and throw on errors.