Add-OfficeExcelTable
Writes tabular data to the current worksheet and formats it as an Excel table.
Syntax
Add-OfficeExcelTable
[-Address <String>]
[-CollectionSeparator <String>]
[-ColumnFormat <Hashtable>]
[-Culture <CultureInfo>]
[-Document <ExcelDocument>]
[-FlattenOptions <OfficeObjectFlattenOptions>]
[-InputObject] <Object>
[-Name <String>]
[-NoAutoFilter]
[-NoAutoFit]
[-NoFreeze]
[-NoHeader]
[-NoRowStripes]
[-NoTable]
[-NoTableStyle]
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[-ShowColumnStripes]
[-ShowFirstColumn]
[-ShowLastColumn]
[-TableStyle <ExcelTableStyle>]
[-View <Normal| Transpose>]
[<CommonParameters>]#DefaultDescription
Accepts objects, dictionaries, DataTable/DataView/IDataReader inputs, or DataRow sequences and writes them into an Excel table with optional styling.
Examples
Write objects as a table
New-OfficeExcel -Path .\Services.xlsx {
ExcelSheet 'Services' {
ExcelTable (Get-Service)
}
}Writes the services as a themed table with a frozen header, filters and fitted columns.
Place two named tables on a sheet
$targets = Import-OfficeCsv -Path .\Data\Q3-Targets.csv
$actuals = Import-OfficeCsv -Path .\Data\Q3-Actuals.csv
New-OfficeExcel -Path .\Reports\Q3-Performance.xlsx {
ExcelSheet 'Performance' {
ExcelTable $targets -Name Targets -Address A1
ExcelTable $actuals -Name Actuals -Address G1 -ColumnFormat @{ Attainment = 'Percent' }
}
}Writes this quarter's targets and actuals side by side as named tables, so charts, formulas and later imports can refer to them by name.
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.
- -Document ExcelDocument
- Caller-owned workbook; omission uses the enclosing Excel content block.
- -FlattenOptions OfficeObjectFlattenOptions
- Nested-value projection policy; accepts a native options object or hashtable.
- -InputObject Object
- Objects, dictionaries or native tabular data supplied directly or through the pipeline.
- -Name String
- Name to assign to the table.
- -NoAutoFilter SwitchParameter
- Omits table filter buttons.
- -NoAutoFit SwitchParameter
- Retains native column widths without fitting them to the data.
- -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.
- -Sheet OfficeSheetSelector
- Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
- -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.
- -TableStyle ExcelTableStyle
- 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
- Projection to apply before writing the table.
- Possible values:
Normal,Transpose
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.