Cmdlet
Add-OfficePdfTable
Adds a table to a PDF document.
Syntax
Add-OfficePdfTable
[-Alignment <OfficeAlignment>]
[-AutoFit]
[-BandColor <OfficeColor>]
[-BorderColor <OfficeColor>]
[-BorderWidth <OfficeLength>]
[-Caption <String>]
[-CaptionAlignment <OfficeAlignment>]
[-CaptionColor <OfficeColor>]
[-CaptionSize <OfficeLength>]
[-CellPaddingX <OfficeLength>]
[-CellPaddingY <OfficeLength>]
[-CollectionSeparator <String>]
[-Color <OfficeColor>]
[-ColumnAlignment <OfficeAlignment[]>]
[-ColumnFormat <Hashtable>]
[-ColumnWeight <Double[]>]
[-ColumnWidth <OfficeLength[]>]
[-DictionaryEntrySeparator <String>]
[-DictionaryKeyValueSeparator <String>]
[-FooterRowCount <Int32>]
[-Header <String[]>]
[-HeaderBackgroundColor <OfficeColor>]
[-HeaderColor <OfficeColor>]
[-HeaderRowCount <Int32>]
[-HeaderSize <OfficeLength>]
[-InputObject] <Object[]>
[-KeepTogether]
[-KeepWithNext]
[-LineHeight <Double>]
[-MaxCollectionItems <Int32>]
[-MaxNestingDepth <Int32>]
[-MinimumSize <OfficeLength>]
[-NoBanding]
[-NoBorder]
[-NoHeaderBackground]
[-NoNumericAlignment]
[-PageSummary <PdfTablePageSummary>]
[-Property <String[]>]
[-RepeatFooterRows]
[-RepeatHeaderRowCount <Int32>]
[-ShrinkToFit]
[-Size <OfficeLength>]
[-SpacingAfter <OfficeLength>]
[-SpacingBefore <OfficeLength>]
[-TableStyle <String>]
[-View <Normal| Transpose>]
[<CommonParameters>]#Parameter set:
ContextAdd-OfficePdfTable
[-Alignment <OfficeAlignment>]
[-AutoFit]
[-BandColor <OfficeColor>]
[-BorderColor <OfficeColor>]
[-BorderWidth <OfficeLength>]
[-Caption <String>]
[-CaptionAlignment <OfficeAlignment>]
[-CaptionColor <OfficeColor>]
[-CaptionSize <OfficeLength>]
[-CellPaddingX <OfficeLength>]
[-CellPaddingY <OfficeLength>]
[-CollectionSeparator <String>]
[-Color <OfficeColor>]
[-ColumnAlignment <OfficeAlignment[]>]
[-ColumnFormat <Hashtable>]
[-ColumnWeight <Double[]>]
[-ColumnWidth <OfficeLength[]>]
[-DictionaryEntrySeparator <String>]
[-DictionaryKeyValueSeparator <String>]
-Document <PdfDocument>
[-FooterRowCount <Int32>]
[-Header <String[]>]
[-HeaderBackgroundColor <OfficeColor>]
[-HeaderColor <OfficeColor>]
[-HeaderRowCount <Int32>]
[-HeaderSize <OfficeLength>]
[-InputObject] <Object[]>
[-KeepTogether]
[-KeepWithNext]
[-LineHeight <Double>]
[-MaxCollectionItems <Int32>]
[-MaxNestingDepth <Int32>]
[-MinimumSize <OfficeLength>]
[-NoBanding]
[-NoBorder]
[-NoHeaderBackground]
[-NoNumericAlignment]
[-PageSummary <PdfTablePageSummary>]
[-PassThru]
[-Property <String[]>]
[-RepeatFooterRows]
[-RepeatHeaderRowCount <Int32>]
[-ShrinkToFit]
[-Size <OfficeLength>]
[-SpacingAfter <OfficeLength>]
[-SpacingBefore <OfficeLength>]
[-TableStyle <String>]
[-View <Normal| Transpose>]
[<CommonParameters>]#Parameter set:
DocumentAdd-OfficePdfTable
[-Alignment <OfficeAlignment>]
[-AutoFit]
[-BandColor <OfficeColor>]
[-BorderColor <OfficeColor>]
[-BorderWidth <OfficeLength>]
[-Caption <String>]
[-CaptionAlignment <OfficeAlignment>]
[-CaptionColor <OfficeColor>]
[-CaptionSize <OfficeLength>]
[-CellPaddingX <OfficeLength>]
[-CellPaddingY <OfficeLength>]
[-CollectionSeparator <String>]
[-Color <OfficeColor>]
[-ColumnAlignment <OfficeAlignment[]>]
[-ColumnFormat <Hashtable>]
[-ColumnWeight <Double[]>]
[-ColumnWidth <OfficeLength[]>]
[-DictionaryEntrySeparator <String>]
[-DictionaryKeyValueSeparator <String>]
-Document <PdfDocument>
[-FooterRowCount <Int32>]
[-Header <String[]>]
[-HeaderBackgroundColor <OfficeColor>]
[-HeaderColor <OfficeColor>]
[-HeaderRowCount <Int32>]
[-HeaderSize <OfficeLength>]
[-InputObject] <Object[]>
[-KeepTogether]
[-KeepWithNext]
[-LineHeight <Double>]
[-MaxCollectionItems <Int32>]
[-MaxNestingDepth <Int32>]
[-MinimumSize <OfficeLength>]
[-NoBanding]
[-NoBorder]
[-NoHeaderBackground]
[-NoNumericAlignment]
[-PageSummary <PdfTablePageSummary>]
[-PassThru]
[-Property <String[]>]
[-RepeatFooterRows]
[-RepeatHeaderRowCount <Int32>]
[-ShrinkToFit]
[-Size <OfficeLength>]
[-SpacingAfter <OfficeLength>]
[-SpacingBefore <OfficeLength>]
[-TableStyle <String>]
[-View <Normal| Transpose>]
[<CommonParameters>]#Parameter set:
PipelineDocumentExamples
Add object data as a PDF table.
$services = @(
[pscustomobject]@{ Name = 'Directory'; Status = 'Healthy'; Incidents = 0 }
[pscustomobject]@{ Name = 'Mail'; Status = 'Watch'; Incidents = 2 }
)
New-OfficePdf -Path .\Examples\Documents\PdfTable.pdf {
Add-OfficePdfHeading -Text 'Service status'
Add-OfficePdfTable -InputObject $services -Property Name,Status,Incidents -Header 'Service','Status','Incidents'
}Converts PowerShell objects into a table using selected properties and friendly headers.
Carry invoice amounts across pages.
$summary = [OfficeIMO.Pdf.PdfTablePageSummary]::new()
$amount = $summary.Sum('amount', 2, 'N2', $null)
$null = $summary.AddContinuationHeaderRow([string[]] @('Brought forward', '', $amount.BroughtForwardToken))
$null = $summary.AddPageFooterRow([string[]] @('Carried forward', '', $amount.RunningToken))
$lines = 1..120 | ForEach-Object { [pscustomobject]@{ Item = $_; Description = 'Consulting hour'; Amount = '125.00' } }
$lines += [pscustomobject]@{ Item = 'Total'; Description = ''; Amount = $amount.RunningToken }
New-OfficePdf -Path .\Examples\Documents\PdfInvoiceLines.pdf {
Add-OfficePdfTable -InputObject $lines -FooterRowCount 1 -PageSummary $summary
}Each page that continues ends with the running amount, and the next page starts with the amount brought forward.
Parameters
- -Alignment OfficeAlignment
- Table alignment.
- Possible values:
Left,Center,Right,Justify,Start,End - -AutoFit SwitchParameter
- Measure flexible columns from content.
- -BandColor OfficeColor
- Alternating body row fill color. Named colors and hexadecimal values are accepted.
- -BorderColor OfficeColor
- Border color. Named colors and hexadecimal values are accepted.
- -BorderWidth OfficeLength
- Border width in PDF points.
- -Caption String
- Caption rendered above the table grid.
- -CaptionAlignment OfficeAlignment
- Caption alignment.
- Possible values:
Left,Center,Right,Justify,Start,End - -CaptionColor OfficeColor
- Caption color. Named colors and hexadecimal values are accepted.
- -CaptionSize OfficeLength
- Caption font size in PDF points.
- -CellPaddingX OfficeLength
- Horizontal cell padding in PDF points.
- -CellPaddingY OfficeLength
- Vertical cell padding in PDF points.
- -CollectionSeparator String
- Text used between items when a property or cell contains a collection.
- -Color OfficeColor
- Body text color. Named colors and hexadecimal values are accepted.
- -ColumnAlignment OfficeAlignment[]
- Per-column horizontal alignment.
- Possible values:
Left,Center,Right,Justify,Start,End - -ColumnFormat Hashtable
- Invariant .NET display formats keyed by selected property name.
- -ColumnWeight Double[]
- Relative column width weights.
- -ColumnWidth OfficeLength[]
- Fixed column widths in PDF points.
- -DictionaryEntrySeparator String
- Text used between entries when a cell contains a dictionary.
- -DictionaryKeyValueSeparator String
- Text used between a dictionary key and value.
- Number of trailing rows rendered as footer rows.
- -Header String[]
- Header labels. Defaults to property names.
- -HeaderBackgroundColor OfficeColor
- Header fill color. Named colors and hexadecimal values are accepted.
- -HeaderColor OfficeColor
- Header text color. Named colors and hexadecimal values are accepted.
- -HeaderRowCount Int32
- Number of leading rows rendered as header rows.
- -HeaderSize OfficeLength
- Header cell font size in PDF points.
- -InputObject Object[]
- Objects or row arrays to render as a table.
- -KeepTogether SwitchParameter
- Keep the table together when possible.
- -KeepWithNext SwitchParameter
- Keep the table with the next block when possible.
- -LineHeight Double
- Wrapped line height multiplier for table cells.
- -MaxCollectionItems Int32
- 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
- Maximum nesting depth allowed while normalizing one cell value. Defaults to 64; increase explicitly for trusted deeper values.
- -MinimumSize OfficeLength
- Smallest font size, in points, used by -ShrinkToFit.
- -NoBanding SwitchParameter
- Disable alternating row fill.
- -NoBorder SwitchParameter
- Hide table borders.
- -NoHeaderBackground SwitchParameter
- Disable the header fill.
- -NoNumericAlignment SwitchParameter
- Right-align numeric-looking cell values.
- -PageSummary PdfTablePageSummary
- Per-page aggregates and summary rows, such as page subtotals and carried-forward or brought-forward amounts. Footer rows and summary rows can show aggregate tokens such as {page:amount}, {broughtForward:amount} and {running:amount}.
- -Property String[]
- Specific object properties to include.
- Close every page of a table that continues across pages with its footer rows, not only the last page.
- -RepeatHeaderRowCount Int32
- Number of leading header rows repeated on following pages.
- -ShrinkToFit SwitchParameter
- Reduce table text size when needed so cell text fits within the resolved cell width.
- -Size OfficeLength
- Body cell font size in PDF points.
- -SpacingAfter OfficeLength
- Spacing after the table in PDF points.
- -SpacingBefore OfficeLength
- Spacing before the table in PDF points.
- -TableStyle String
- OfficeIMO table style preset or supported Word table style name.
- -View OfficeTableView
- Projection to apply before writing the table.
- Possible values:
Normal,Transpose - -Document PdfDocument
- PDF document to update outside the DSL context.
- -PassThru SwitchParameter
- Emit the updated document.
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.