# Close-OfficeExcel

Closes an Excel workbook and optionally saves it. Review available syntax, parameters, pipeline guidance, and reference details in PSWriteOffice API Reference.

Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

[View on GitHub](https://github.com/EvotecIT/OfficeIMO/tree/master/PowerShell/PSWriteOffice) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteOffice/releases/tag/v3.0.5) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteOffice/0.2.0)

Stars **727**

Forks **84**

Open issues **7**

Total downloads **5,275,783**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-24

Cmdlet 

**Module**

`PSWriteOffice`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Source**

[CloseOfficeExcelCommand.cs:23](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Excel/CloseOfficeExcelCommand.cs#L23) 

Closes an Excel workbook and optionally saves it.

## Syntax

```
Close-OfficeExcel
[-ClearCachedFormulaResults]
[-DateSystem <1900|1904|NineteenHundred|NineteenFour>]
[-DisableFastPackageWriter]
-Document <ExcelDocument>
[-EvaluateFormulas]
[-ForceFullCalculationOnOpen]
[-MarkFormulasDirty]
[-Open]
[-Password <String>]
[-Path <String>]
[-SafePreflight]
[-SafeRepairDefinedNames]
[-Save]
[-ValidateOpenXml]
[<CommonParameters>]
```

[#](#member-e61fbb505e7bb5b7b7ed6137)

Parameter set: `All Parameter Sets`

## Description

Convenience wrapper so scripts do not need to call Save or Dispose directly.

## Examples

### Save, validate, and close an open workbook.

```powershell
New-OfficeExcel -Path .\report.xlsx {
    Add-OfficeExcelSheet -Name Data {
        Set-OfficeExcelRow -Row 1 -Values 'Region', 'Revenue'
        Set-OfficeExcelRow -Row 2 -Values 'EMEA', 98000
    }
}
$workbook = Get-OfficeExcel -Path .\report.xlsx
$workbook | Close-OfficeExcel -Save -Path .\report-final.xlsx -SafePreflight -ValidateOpenXml
```

Saves pending changes through OfficeIMO's normal save path, validates the package, and releases the workbook.

## Parameters

**-ClearCachedFormulaResults SwitchParameter optional**

Remove cached formula results before saving.

**-DateSystem String optional**

Workbook date system for Excel date serials.

Possible values: `1900`, `1904`, `NineteenHundred`, `NineteenFour`

**-DisableFastPackageWriter SwitchParameter optional**

Disable OfficeIMO fast package writers for this save.

**-Document ExcelDocument requiredpipeline: True (ByValue)**

Workbook to close.

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

**-MarkFormulasDirty SwitchParameter optional**

Mark formula cells dirty before saving.

**-Open SwitchParameter optionalaliases: Show**

Open the workbook after saving. Requires -Save or -Path.

**-Password String optional**

Password used to save the workbook as an encrypted package.

**-Path String optional**

Optional output path when saving.

**-SafePreflight SwitchParameter optional**

Run OfficeIMO worksheet preflight cleanup before saving.

**-SafeRepairDefinedNames SwitchParameter optional**

Repair common defined-name issues before saving.

**-Save SwitchParameter optional**

Persist changes before closing.

**-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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:AA8CDF740E6C7A8DA476A05DFACB91A13D79E61123249A6D1748E2937D246154 -->
