Project

PSWriteOffice

PowerShell document automation across Word, Excel, PowerPoint, PDF, Reader, Confluence, Visio, and open text formats.

Stars 159
Forks 14
PowerShell Gallery downloads 158,661
Release v3.0.5
Language: C# Updated: 2026-09-03

API Reference

Cmdlet

Add-OfficeExcelTable

Aliases: ExcelTable
Namespace PSWriteOffice
Aliases
ExcelTable
Inputs
System.Object

Writes tabular data to the current worksheet and formats it as an Excel table.

Remarks

Accepts objects, dictionaries, DataTable/DataView/IDataReader inputs, or DataRow sequences and writes them into an Excel table with optional styling.

Examples

Authored help example

Insert a table starting at A1.

PS>


$data = @([pscustomobject]@{ Region='NA'; Revenue=100 }, [pscustomobject]@{ Region='EMEA'; Revenue=150 })
              ExcelSheet 'Data' { Add-OfficeExcelTable -InputObject $data -TableName 'Sales' }
        

Writes two rows and formats them as a styled Excel table.

Add a table to an explicit worksheet.

PS>


Add-OfficeExcelTable -Worksheet $sheet -InputObject $rows -TableName 'Sales' -AutoFit
        

Writes the rows into a live workbook without requiring an active DSL scope.

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.

Syntax

Add-OfficeExcelTable [-AutoFit] [-CollectionSeparator <String>] [-DictionaryEntrySeparator <String>] [-DictionaryKeyValueSeparator <String>] [-Document <ExcelDocument>] -InputObject <Object> [-MaxCollectionItems <Int32>] [-MaxNestingDepth <Int32>] [-NoAutoFilter] [-NoHeader] [-NoRowStripes] [-PassThru] [-Sheet <String>] [-SheetIndex <Int32>] [-ShowColumnStripes] [-ShowFirstColumn] [-ShowLastColumn] [-StartColumn <Int32>] [-StartRow <Int32>] [-TableName <String>] [-TableStyle <TableStyleLight1>] [-View <Normal|Transpose>] [-Worksheet <ExcelSheet>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Parameters

AutoFit SwitchParameter optionalposition: namedpipeline: False
Auto-fit the table columns after insertion.
CollectionSeparator String optionalposition: namedpipeline: False
Text used between items when a cell contains a collection.
DictionaryEntrySeparator String optionalposition: namedpipeline: False
Text used between entries when a cell contains a dictionary.
DictionaryKeyValueSeparator String optionalposition: namedpipeline: False
Text used between a dictionary key and value.
Document ExcelDocument optionalposition: namedpipeline: False
Workbook that will receive the table outside a DSL context.
InputObject Object requiredposition: 0pipeline: True (ByValue)aliases: Data, DataTable
Source objects, dictionaries, DataTable/DataView/IDataReader inputs, or DataRow sequences to convert into table rows.
MaxCollectionItems Int32 optionalposition: namedpipeline: False
Maximum number of items allowed in one nested collection or dictionary cell. Defaults to 1,048,575; increase explicitly for trusted larger values.
MaxNestingDepth Int32 optionalposition: namedpipeline: False
Maximum nesting depth allowed while normalizing one cell value. Defaults to 64; increase explicitly for trusted deeper values.
NoAutoFilter SwitchParameter optionalposition: namedpipeline: False
Disable AutoFilter dropdowns.
NoHeader SwitchParameter optionalposition: namedpipeline: False
Skip writing headers.
NoRowStripes SwitchParameter optionalposition: namedpipeline: False
Disable alternating row stripes for the created table.
PassThru SwitchParameter optionalposition: namedpipeline: False
Return the created range string.
Sheet String optionalposition: namedpipeline: False
Worksheet name when using Document.
SheetIndex Int32 optionalposition: namedpipeline: False
Worksheet index (0-based) when using Document.
ShowColumnStripes SwitchParameter optionalposition: namedpipeline: False
Enable alternating column stripes for the created table.
ShowFirstColumn SwitchParameter optionalposition: namedpipeline: False
Emphasize the first table column when the selected style supports it.
ShowLastColumn SwitchParameter optionalposition: namedpipeline: False
Emphasize the last table column when the selected style supports it.
StartColumn Int32 optionalposition: namedpipeline: False
Starting column for the data (1-based).
StartRow Int32 optionalposition: namedpipeline: False
Starting row for the data (1-based).
TableName String optionalposition: namedpipeline: False
Name to assign to the table.
TableStyle ExcelTableStyle optionalposition: namedpipeline: Falsevalues: 60
Built-in table style to apply.
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
View OfficeTableView optionalposition: namedpipeline: Falsevalues: 2
Projection to apply before writing the table.
Possible values: Normal, Transpose
Worksheet ExcelSheet optionalposition: namedpipeline: Falsealiases: SheetObject
Worksheet that will receive the table outside a DSL context.