Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

New-OfficeOpenDocument

Aliases: OfficeOpenDocument, OpenDocumentNew
Module PSWriteOffice
Aliases
OfficeOpenDocument OpenDocumentNew
Inputs
None
Outputs
OfficeIMO.OpenDocument.OdfDocument System.IO.FileInfo

Creates a native ODT, ODS, ODP, or ODG document.

Syntax

New-OfficeOpenDocument [[-Content] <ScriptBlock>] [-Kind] <Text|Spreadsheet|Presentation|Graphics> [-NoSave] [-PassThru] [[-Path] <String>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Examples

Authored help example

Create an OpenDocument text report.

New-OfficeOpenDocument -Kind Text -Path .\Report.odt -Content {
    Add-OfficeOpenDocumentHeading -Text 'Service report' -Level 1
    Add-OfficeOpenDocumentParagraph -Text 'Generated by PSWriteOffice.'
}

Create an OpenDocument drawing through its native object model.

$drawing = New-OfficeOpenDocument -Kind Graphics
$page = $drawing.AddPage('Overview')
$drawing | Save-OfficeOpenDocument -Path .\Overview.odg

Create a spreadsheet with typed cells.

New-OfficeOpenDocument -Kind Spreadsheet -Path .\Status.ods -Content {
    Add-OfficeOpenDocumentSheet -Name 'Services' -Content {
        Set-OfficeOpenDocumentCell -Row 0 -Column 0 -Value 'Service'
        Set-OfficeOpenDocumentCell -Row 0 -Column 1 -Value 'Healthy'
        Set-OfficeOpenDocumentCell -Row 1 -Column 0 -Value 'Directory'
        Set-OfficeOpenDocumentCell -Row 1 -Column 1 -Value $true
    }
}

Parameters

-Content ScriptBlock optionalposition: 2
DSL scriptblock describing OpenDocument text, spreadsheet, or presentation content.
-Kind OdfDocumentKind requiredposition: 0
OpenDocument text, spreadsheet, presentation, or graphics kind.
Possible values: Text, Spreadsheet, Presentation, Graphics
-NoSave SwitchParameter optional
Skip saving and emit the live OpenDocument model even when -Path is supplied.
-PassThru SwitchParameter optional
Emit the saved file when a destination path is supplied.
-Path String optionalposition: 1
Optional initial destination path.

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.