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

New-OfficeExcel

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

Creates a new Excel workbook using the DSL.

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

Description

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

Examples

Create a workbook with a sheet and a few cells.

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.

$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.

Parameters

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

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.