Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Export-OfficeExcel

Module
PSWriteOffice
Inputs
System.Object

Exports PowerShell objects to an Excel workbook using an operator-friendly surface.

Syntax

Export-OfficeExcel
[-Address <String>]
[-CollectionSeparator <String>]
[-ColumnFormat <Hashtable>]
[-Culture <CultureInfo>]
[-DateSystem <NineteenHundred|NineteenFour>]
[-DateTimeOffsetMode <Text|Serial>]
[-Decimals <Int32>]
[-DocumentProperty <Hashtable>]
[-ExcludeProperty <String[]>]
[-FlattenOptions <OfficeObjectFlattenOptions>]
[-FreezeFirstColumn]
[-IgnoreMissingColumnFormat]
[-InputObject <Object>]
[-NoAutoFilter]
[-NoAutoFit]
[-NoClobber]
[-NoFreeze]
[-NoHeader]
[-NoRowStripes]
[-NoTable]
[-NoTableStyle]
[-PassThru]
[-Path] <String>
[-SaveOptions <ExcelSaveOptions>]
[-Sheet <OfficeSheetSelector>]
[-Show]
[-ShowColumnStripes]
[-ShowFirstColumn]
[-ShowLastColumn]
[-TableName <String>]
[-TableStyle <ExcelTableStyle>]
[-Theme <OfficeThemeInput>]
[-Title <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
#
Parameter set: Create
Export-OfficeExcel
[-Address <String>]
-Append
[-CollectionSeparator <String>]
[-ColumnFormat <Hashtable>]
[-Culture <CultureInfo>]
[-DateSystem <NineteenHundred|NineteenFour>]
[-DateTimeOffsetMode <Text|Serial>]
[-Decimals <Int32>]
[-DocumentProperty <Hashtable>]
[-ExcludeProperty <String[]>]
[-FlattenOptions <OfficeObjectFlattenOptions>]
[-FreezeFirstColumn]
[-IgnoreMissingColumnFormat]
[-InputObject <Object>]
[-NoAutoFilter]
[-NoAutoFit]
[-NoFreeze]
[-NoHeader]
[-NoRowStripes]
[-NoTable]
[-NoTableStyle]
[-PassThru]
[-Path] <String>
[-SaveOptions <ExcelSaveOptions>]
[-Sheet <OfficeSheetSelector>]
[-Show]
[-ShowColumnStripes]
[-ShowFirstColumn]
[-ShowLastColumn]
[-TableName <String>]
[-TableStyle <ExcelTableStyle>]
[-Theme <OfficeThemeInput>]
[-Title <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
#
Parameter set: Append
Export-OfficeExcel
[-Address <String>]
[-CollectionSeparator <String>]
[-ColumnFormat <Hashtable>]
[-Culture <CultureInfo>]
[-DateSystem <NineteenHundred|NineteenFour>]
[-DateTimeOffsetMode <Text|Serial>]
[-Decimals <Int32>]
[-DocumentProperty <Hashtable>]
[-ExcludeProperty <String[]>]
[-FlattenOptions <OfficeObjectFlattenOptions>]
[-FreezeFirstColumn]
[-IgnoreMissingColumnFormat]
[-InputObject <Object>]
[-NoAutoFilter]
[-NoAutoFit]
[-NoFreeze]
[-NoHeader]
[-NoRowStripes]
[-NoTable]
[-NoTableStyle]
[-PassThru]
[-Path] <String>
-ReplaceSheet
[-SaveOptions <ExcelSaveOptions>]
[-Sheet <OfficeSheetSelector>]
[-Show]
[-ShowColumnStripes]
[-ShowFirstColumn]
[-ShowLastColumn]
[-TableName <String>]
[-TableStyle <ExcelTableStyle>]
[-Theme <OfficeThemeInput>]
[-Title <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
#
Parameter set: ReplaceSheet

Description

Provides a fast PowerShell export path while keeping OfficeIMO as the workbook engine.

Examples

Export objects in one line

Get-Process | Export-OfficeExcel -Path .\Processes.xlsx -Show

Writes the running processes as a styled table with a frozen header and fitted columns, and opens the file.

Export a titled sales sheet

$export = @{
    Path         = '.\Reports\Q3-Sales.xlsx'
    Sheet        = 'Orders'
    TableName    = 'Orders'
    Title        = 'Q3 orders'
    ColumnFormat = @{ Margin = 'Percent' }
}
Import-OfficeCsv -Path .\Data\Q3-Orders.csv |
    Select-Object OrderId, Customer, Region, OrderDate, Amount, Margin |
    Export-OfficeExcel @export

Exports the Q3 orders as a named table under a title; dates and amounts are formatted from the data, and only the margin column is set explicitly as a percentage.

Append a daily snapshot to a history table

Get-Volume |
                Where-Object DriveLetter |
                Select-Object @{ Name = 'Date'; Expression = { Get-Date } }, DriveLetter, Size, SizeRemaining |
                Export-OfficeExcel -Path .\Reports\Disk-Usage.xlsx -Sheet History -TableName DiskHistory -Append

Adds today's free-space readings to the DiskHistory table, so the workbook grows into a capacity history one run at a time.

Refresh one sheet of a workbook

Import-OfficeCsv -Path .\Exports\open-tickets.csv |
                Export-OfficeExcel -Path .\Reports\Helpdesk.xlsx -Sheet 'Open tickets' -ReplaceSheet

Replaces only the Open tickets sheet with this morning's export and leaves the other sheets, charts and notes in the workbook untouched.

Parameters

-Address String optional
A1 address of the target cell.
-CollectionSeparator String optional
Text inserted between collection values flattened into one cell.
-ColumnFormat Hashtable optional
Maps column headers to number-format presets, format codes or per-column option hashtables.
-Culture CultureInfo optional
Culture used for value conversion and number-format presets.
-DateSystem ExcelDateSystem optional
Workbook date system for Excel date serials.
Possible values: NineteenHundred, NineteenFour
-DateTimeOffsetMode ExcelDateTimeOffsetWriteMode optional
How DateTimeOffset values are written: Text (default) keeps the offset as ISO 8601 text; Serial writes local-time Excel dates.
Possible values: Text, Serial
-Decimals Int32 optional
Decimal places used for decimal, percent, currency, and scientific presets.
-DocumentProperty Hashtable optional
Workbook metadata keyed by native property name, such as Title, Author or Company.
-ExcludeProperty String[] optional
Exclude specific properties from exported objects.
-FlattenOptions OfficeObjectFlattenOptions optional
Nested-value projection policy; accepts a native options object or hashtable.
-FreezeFirstColumn SwitchParameter optional
Freeze the first exported column.
-IgnoreMissingColumnFormat SwitchParameter optional
Continue when a requested export-time column format header is missing.
-InputObject Object optionalpipeline: True (ByValue)
Objects, dictionaries or native tabular data supplied directly or through the pipeline.
-NoAutoFilter SwitchParameter optional
Omits table filter buttons.
-NoAutoFit SwitchParameter optional
Retains native column widths without fitting them to the data.
-NoClobber SwitchParameter optionalsets: Create
Do not overwrite an existing workbook.
-NoFreeze SwitchParameter optional
Keeps the header row scrollable.
-NoHeader SwitchParameter optional
Writes data without a header row.
-NoRowStripes SwitchParameter optional
Disables alternating row bands. An explicit false value enables them.
-NoTable SwitchParameter optional
Writes plain cells without creating a native Excel table.
-NoTableStyle SwitchParameter optional
Creates the table without a named visual style.
-PassThru SwitchParameter optional
Emits the native result after the operation.
-Path String requiredposition: 0aliases: FilePath
Workbook paths resolved with filesystem wildcard support.
-SaveOptions ExcelSaveOptions optional
Native save options or a hashtable, applied to a completed content block.
-Sheet OfficeSheetSelector optionalaliases: WorksheetName
Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
-Show SwitchParameter optional
Open the saved file in its registered application after a local block completes.
-ShowColumnStripes SwitchParameter optional
Enables alternating column bands; explicit false clears them.
-ShowFirstColumn SwitchParameter optional
Emphasizes the first table column; explicit false removes the emphasis.
-ShowLastColumn SwitchParameter optional
Emphasizes the last table column; explicit false removes the emphasis.
-TableName String optional
Optional Excel table name.
-TableStyle ExcelTableStyle optional
Built-in Excel table style name.
Possible values: TableStyleLight1, TableStyleLight2, TableStyleLight3, TableStyleLight4, TableStyleLight5, TableStyleLight6, TableStyleLight7, TableStyleLight8, TableStyleLight9, TableStyleLight10, TableStyleLight11, TableStyleLight12, TableStyleLight13, TableStyleLight14, TableStyleLight15, TableStyleLight16, TableStyleLight17, TableStyleLight18, TableStyleLight19, TableStyleLight20, TableStyleLight21, TableStyleMedium1, TableStyleMedium2, TableStyleMedium3, TableStyleMedium4, TableStyleMedium5, TableStyleMedium6, TableStyleMedium7, TableStyleMedium8, TableStyleMedium9, TableStyleMedium10, TableStyleMedium11, TableStyleMedium12, TableStyleMedium13, TableStyleMedium14, TableStyleMedium15, TableStyleMedium16, TableStyleMedium17, TableStyleMedium18, TableStyleMedium19, TableStyleMedium20, TableStyleMedium21, TableStyleMedium22, TableStyleMedium23, TableStyleMedium24, TableStyleMedium25, TableStyleMedium26, TableStyleMedium27, TableStyleMedium28, TableStyleDark1, TableStyleDark2, TableStyleDark3, TableStyleDark4, TableStyleDark5, TableStyleDark6, TableStyleDark7, TableStyleDark8, TableStyleDark9, TableStyleDark10, TableStyleDark11
-Theme OfficeThemeInput optional
Built-in Office theme, native theme object or a document whose visual theme is read.
-Title String optional
Write a title above the exported table.
-WhatIf SwitchParameter optional
Shows what would happen if the command runs.
-Confirm SwitchParameter optional
Prompts for confirmation before running the command.
-Append SwitchParameter requiredsets: Append
Append rows to an existing worksheet when the workbook exists.
-ReplaceSheet SwitchParameter requiredsets: ReplaceSheet
Replaces the selected worksheet while retaining other workbook content.

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.