API Reference
Cmdlet
Add-OfficeWordChart
Adds a chart to a Word document.
Remarks
Creates a Word chart from object data using one category property and one or more numeric series properties.
Examples
Add pie and line charts to a report.
PS>
$rows = @(
[pscustomobject]@{ Region = 'North America'; Revenue = 125000; Profit = 42000 }
[pscustomobject]@{ Region = 'EMEA'; Revenue = 98000; Profit = 31000 }
[pscustomobject]@{ Region = 'APAC'; Revenue = 143000; Profit = 52000 }
)
New-OfficeWord -Path .\RegionalReport.docx {
Add-OfficeWordParagraph -Text 'Regional revenue'
Add-OfficeWordChart -Type Pie -InputObject $rows -CategoryProperty Region -SeriesProperty Revenue -Title 'Revenue mix' -FitToPageWidth -WidthFraction 0.75
Add-OfficeWordChart -Type Bar -InputObject $rows -CategoryProperty Region -SeriesProperty Revenue, Profit -Legend -XAxisTitle 'Region' -YAxisTitle 'Amount'
}
Creates a report with a pie chart and a multi-series bar chart from PowerShell objects.
Add a line chart to an open document.
PS>
$trend = @(
[pscustomobject]@{ Month = 'Jan'; Sales = 10; Profit = 4 }
[pscustomobject]@{ Month = 'Feb'; Sales = 12; Profit = 5 }
[pscustomobject]@{ Month = 'Mar'; Sales = 15; Profit = 7 }
)
$doc = New-OfficeWord -Path .\Trend.docx -PassThru
Add-OfficeWordChart -Document $doc -Type Line -InputObject $trend -CategoryProperty Month -SeriesProperty Sales, Profit -Legend -Title 'Quarter trend'
Save-OfficeWord -Document $doc
Creates a multi-series line chart on the document and shows a legend.
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-OfficeWordChart -CategoryProperty <String> [-FitToPageWidth] [-HeightPixels <Int32>] -InputObject <Object[]> [-Legend] [-LegendPosition <Left|Right|Top|Bottom|TopRight>] [-PassThru] [-SeriesColor <String[]>] -SeriesProperty <String[]> [-Title <String>] [-Type <Pie|Bar|Line|Area>] [-WidthFraction <Double>] [-WidthPixels <Int32>] [-XAxisTitle <String>] [-YAxisTitle <String>] [<CommonParameters>]#Parameter set:
ContextParameters
- CategoryProperty String
- Property name used for category labels.
- FitToPageWidth SwitchParameter
- Scale the chart width to the page content width.
- HeightPixels Int32
- Chart height in pixels.
- InputObject Object[]
- Source objects used to build chart data.
- Legend SwitchParameter
- Add a legend to the chart.
- LegendPosition String
- Legend position when -Legend is used.
- Possible values:
Left,Right,Top,Bottom,TopRight - PassThru SwitchParameter
- Emit the created chart.
- SeriesColor String[]
- Color values applied to the series in order.
- SeriesProperty String[]
- Property names used as numeric series.
- Title String
- Optional chart title.
- Type WordChartType
- Chart type to create.
- Possible values:
Pie,Bar,Line,Area - WidthFraction Double
- Fraction of the page content width to use when -FitToPageWidth is specified.
- WidthPixels Int32
- Chart width in pixels.
- XAxisTitle String
- Optional X axis title for non-pie charts.
- YAxisTitle String
- Optional Y axis title for non-pie charts.
Outputs
OfficeIMO.Word.WordChart
Add-OfficeWordChart -CategoryProperty <String> [-Document <WordDocument>] [-FitToPageWidth] [-HeightPixels <Int32>] -InputObject <Object[]> [-Legend] [-LegendPosition <Left|Right|Top|Bottom|TopRight>] [-PassThru] [-SeriesColor <String[]>] -SeriesProperty <String[]> [-Title <String>] [-Type <Pie|Bar|Line|Area>] [-WidthFraction <Double>] [-WidthPixels <Int32>] [-XAxisTitle <String>] [-YAxisTitle <String>] [<CommonParameters>]#Parameter set:
DocumentParameters
- CategoryProperty String
- Property name used for category labels.
- Document WordDocument
- Target document that will receive the chart.
- FitToPageWidth SwitchParameter
- Scale the chart width to the page content width.
- HeightPixels Int32
- Chart height in pixels.
- InputObject Object[]
- Source objects used to build chart data.
- Legend SwitchParameter
- Add a legend to the chart.
- LegendPosition String
- Legend position when -Legend is used.
- Possible values:
Left,Right,Top,Bottom,TopRight - PassThru SwitchParameter
- Emit the created chart.
- SeriesColor String[]
- Color values applied to the series in order.
- SeriesProperty String[]
- Property names used as numeric series.
- Title String
- Optional chart title.
- Type WordChartType
- Chart type to create.
- Possible values:
Pie,Bar,Line,Area - WidthFraction Double
- Fraction of the page content width to use when -FitToPageWidth is specified.
- WidthPixels Int32
- Chart width in pixels.
- XAxisTitle String
- Optional X axis title for non-pie charts.
- YAxisTitle String
- Optional Y axis title for non-pie charts.
Outputs
OfficeIMO.Word.WordChart
Add-OfficeWordChart -CategoryProperty <String> [-FitToPageWidth] [-HeightPixels <Int32>] -InputObject <Object[]> [-Legend] [-LegendPosition <Left|Right|Top|Bottom|TopRight>] [-Paragraph <WordParagraph>] [-PassThru] [-SeriesColor <String[]>] -SeriesProperty <String[]> [-Title <String>] [-Type <Pie|Bar|Line|Area>] [-WidthFraction <Double>] [-WidthPixels <Int32>] [-XAxisTitle <String>] [-YAxisTitle <String>] [<CommonParameters>]#Parameter set:
ParagraphParameters
- CategoryProperty String
- Property name used for category labels.
- FitToPageWidth SwitchParameter
- Scale the chart width to the page content width.
- HeightPixels Int32
- Chart height in pixels.
- InputObject Object[]
- Source objects used to build chart data.
- Legend SwitchParameter
- Add a legend to the chart.
- LegendPosition String
- Legend position when -Legend is used.
- Possible values:
Left,Right,Top,Bottom,TopRight - Paragraph WordParagraph
- Target paragraph used as the chart anchor.
- PassThru SwitchParameter
- Emit the created chart.
- SeriesColor String[]
- Color values applied to the series in order.
- SeriesProperty String[]
- Property names used as numeric series.
- Title String
- Optional chart title.
- Type WordChartType
- Chart type to create.
- Possible values:
Pie,Bar,Line,Area - WidthFraction Double
- Fraction of the page content width to use when -FitToPageWidth is specified.
- WidthPixels Int32
- Chart width in pixels.
- XAxisTitle String
- Optional X axis title for non-pie charts.
- YAxisTitle String
- Optional Y axis title for non-pie charts.
Outputs
OfficeIMO.Word.WordChart