Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Open-OfficeExcel

Module
PSWriteOffice
Inputs
System.String
Outputs
OfficeIMO.Excel.ExcelDocument System.IO.FileInfo

Opens a workbook for explicit editing, or atomically saves a completed content block.

Syntax

Open-OfficeExcel
[-AllowLoss]
[[-Content] <ScriptBlock>]
[-MaxDegreeOfParallelism <Int32>]
[-PassThru]
[-Password <SecureString>]
[-Path] <String>
[-ReadOnly]
[-SaveOptions <ExcelSaveOptions>]
[-Show]
[<CommonParameters>]
#
Parameter set: Path
Open-OfficeExcel
[-AllowLoss]
[[-Content] <ScriptBlock>]
-LiteralPath <String>
[-MaxDegreeOfParallelism <Int32>]
[-PassThru]
[-Password <SecureString>]
[-ReadOnly]
[-SaveOptions <ExcelSaveOptions>]
[-Show]
[<CommonParameters>]
#
Parameter set: LiteralPath
Open-OfficeExcel
[-AllowHttp]
[-MaxDegreeOfParallelism <Int32>]
[-Password <SecureString>]
[-ReadOnly]
[-Uri] <Uri>
[<CommonParameters>]
#
Parameter set: Uri

Description

Opening preserves the workbook's theme and encryption. A failed block leaves its source unchanged. Remote workbooks remain detached; save them with Save-OfficeExcel -Path.

Examples

Open a literal file from the pipeline.

$workbook = Get-Item -LiteralPath './Review[final].xlsx' | Open-OfficeExcel
$workbook | Close-OfficeExcel

Edit and save an existing workbook.

Open-OfficeExcel -Path ./Report.xlsx {
    ExcelSheet 'Data' { ExcelCell -Address B2 -Value 'Reviewed' }
}

Read a detached workbook from HTTPS.

$workbook = Open-OfficeExcel -Uri https://intranet.example.com/Budget.xlsx -ReadOnly
Import-OfficeExcel -Document $workbook -Sheet Budget
Close-OfficeExcel -Document $workbook

Parameters

-AllowLoss SwitchParameter optionalsets: Path, LiteralPath
Explicitly accept native-save reductions in a completed local content block.
-Content ScriptBlock optionalposition: 1sets: Path, LiteralPath
Edit a local workbook and save only after the block completes successfully.
-MaxDegreeOfParallelism Int32 optional
Maximum parallel workers; omission preserves the native execution policy.
-PassThru SwitchParameter optionalsets: Path, LiteralPath
Return the saved FileInfo from a completed local content block.
-Password SecureString optional
Source password as a SecureString, credential, or warned plaintext value.
-Path String requiredposition: 0pipeline: True (ByValue)sets: Path
Workbook path with FileSystem wildcard expansion.
-ReadOnly SwitchParameter optional
Return a read-only live workbook; authoring blocks require writable input.
-SaveOptions ExcelSaveOptions optionalsets: Path, LiteralPath
Native save options or a hashtable, applied only to a completed local content block.
-Show SwitchParameter optionalsets: Path, LiteralPath
Open the saved file in its registered application after a local block completes.
-LiteralPath String requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath
Literal workbook path; accepts FileInfo.FullName and provider PSPath.
-AllowHttp SwitchParameter optionalsets: Uri
Allow HTTP in addition to HTTPS for a remote workbook.
-Uri Uri requiredposition: 0sets: Uri
HTTP or HTTPS workbook loaded without a local save destination.

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.