Export-OfficeExcel
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>]#CreateExport-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>]#AppendExport-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>]#ReplaceSheetDescription
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 -ShowWrites 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 @exportExports 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 -AppendAdds 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' -ReplaceSheetReplaces 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
- A1 address of the target cell.
- -CollectionSeparator String
- Text inserted between collection values flattened into one cell.
- -ColumnFormat Hashtable
- Maps column headers to number-format presets, format codes or per-column option hashtables.
- -Culture CultureInfo
- Culture used for value conversion and number-format presets.
- -DateSystem ExcelDateSystem
- Workbook date system for Excel date serials.
- Possible values:
NineteenHundred,NineteenFour - -DateTimeOffsetMode ExcelDateTimeOffsetWriteMode
- 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
- Decimal places used for decimal, percent, currency, and scientific presets.
- -DocumentProperty Hashtable
- Workbook metadata keyed by native property name, such as Title, Author or Company.
- -ExcludeProperty String[]
- Exclude specific properties from exported objects.
- -FlattenOptions OfficeObjectFlattenOptions
- Nested-value projection policy; accepts a native options object or hashtable.
- -FreezeFirstColumn SwitchParameter
- Freeze the first exported column.
- -IgnoreMissingColumnFormat SwitchParameter
- Continue when a requested export-time column format header is missing.
- -InputObject Object
- Objects, dictionaries or native tabular data supplied directly or through the pipeline.
- -NoAutoFilter SwitchParameter
- Omits table filter buttons.
- -NoAutoFit SwitchParameter
- Retains native column widths without fitting them to the data.
- -NoClobber SwitchParameter
- Do not overwrite an existing workbook.
- -NoFreeze SwitchParameter
- Keeps the header row scrollable.
- -NoHeader SwitchParameter
- Writes data without a header row.
- -NoRowStripes SwitchParameter
- Disables alternating row bands. An explicit false value enables them.
- -NoTable SwitchParameter
- Writes plain cells without creating a native Excel table.
- -NoTableStyle SwitchParameter
- Creates the table without a named visual style.
- -PassThru SwitchParameter
- Emits the native result after the operation.
- -Path String
- Workbook paths resolved with filesystem wildcard support.
- -SaveOptions ExcelSaveOptions
- Native save options or a hashtable, applied to a completed content block.
- -Sheet OfficeSheetSelector
- Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
- -Show SwitchParameter
- Open the saved file in its registered application after a local block completes.
- -ShowColumnStripes SwitchParameter
- Enables alternating column bands; explicit false clears them.
- -ShowFirstColumn SwitchParameter
- Emphasizes the first table column; explicit false removes the emphasis.
- -ShowLastColumn SwitchParameter
- Emphasizes the last table column; explicit false removes the emphasis.
- -TableName String
- Optional Excel table name.
- -TableStyle ExcelTableStyle
- 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
- Built-in Office theme, native theme object or a document whose visual theme is read.
- -Title String
- Write a title above the exported table.
- -WhatIf SwitchParameter
- Shows what would happen if the command runs.
- -Confirm SwitchParameter
- Prompts for confirmation before running the command.
- -Append SwitchParameter
- Append rows to an existing worksheet when the workbook exists.
- -ReplaceSheet SwitchParameter
- 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.