Add-OfficeExcelChart
Adds a native Excel chart from a range, named table or input rows.
Syntax
Add-OfficeExcelChart
-Address <String>
[-ColorStyle <Int32>]
[-Document <ExcelDocument>]
[-Height <OfficeLength>]
[-NoCachedData]
[-NoHeader]
[-PassThru]
[-Preset <Comparison| Trend| Contribution| CompactComparison>]
[-Range] <String>
[-Sheet <OfficeSheetSelector>]
[-Style <Int32>]
[-Title <String>]
[-Type <OfficeChartType>]
[-Width <OfficeLength>]
[<CommonParameters>]#RangeAdd-OfficeExcelChart
-Address <String>
[-Category <String>]
[-ColorStyle <Int32>]
[-Document <ExcelDocument>]
[-Height <OfficeLength>]
[-NoCachedData]
[-PassThru]
[-Preset <Comparison| Trend| Contribution| CompactComparison>]
[-Sheet <OfficeSheetSelector>]
[-Style <Int32>]
-Table <String>
[-Title <String>]
[-Type <OfficeChartType>]
[-Value <String[]>]
[-Width <OfficeLength>]
[<CommonParameters>]#TableAdd-OfficeExcelChart
-Address <String>
-Category <String>
[-ColorStyle <Int32>]
[-Document <ExcelDocument>]
[-Height <OfficeLength>]
-InputObject <Object>
[-NoCachedData]
[-PassThru]
[-Preset <Comparison| Trend| Contribution| CompactComparison>]
[-Sheet <OfficeSheetSelector>]
[-Style <Int32>]
[-Title <String>]
[-Type <OfficeChartType>]
-Value <String[]>
[-Width <OfficeLength>]
[<CommonParameters>]#DataDescription
Table columns are selected by header. With no value selection, every numeric column except the category is plotted. Input rows are written as a table below existing worksheet data. Output is quiet unless PassThru is specified.
Examples
Chart a table
New-OfficeExcel -Path .\Reports\Regions.xlsx {
ExcelSheet 'Summary' {
ExcelTable (Import-OfficeCsv -Path .\Data\Region-Revenue.csv) -Name RegionSummary
ExcelChart -Table RegionSummary -Category Region -Value Revenue -Address F2 -Type Column -Title 'Revenue by region'
}
}Adds a themed column chart of the RegionSummary table, anchored at F2.
Chart pipeline data directly
$trend = Import-OfficeCsv -Path .\Data\Ticket-Trend.csv
New-OfficeExcel -Path .\Reports\Helpdesk-Trend.xlsx {
ExcelSheet 'Trend' {
ExcelChart -InputObject $trend -Category Week -Value Opened, Closed -Type Line -Address A1 -Title 'Tickets per week' -Width 18cm -Height 9cm
}
}Writes the weekly ticket trend into the sheet and draws a line chart of opened and closed tickets from it in one step.
Chart a fixed range
Open-OfficeExcel -Path .\Finance\Budget-2027.xlsx {
ExcelSheet 'Summary' {
ExcelChart B3:C15 -Address E3 -Type Bar -Title 'Budget by month'
}
}Charts the monthly budget in B3:C15 of an existing sheet as a clustered bar chart.
Parameters
- -Address String
- Single A1 cell anchoring the top-left corner of the chart.
- -ColorStyle Int32
- Built-in chart color-style identifier.
- -Document ExcelDocument
- Workbook to modify outside an Excel composition block.
- -Height OfficeLength
- Chart height; defaults to 360 pixels. Bare numbers mean points.
- -NoCachedData SwitchParameter
- Omit cached chart values. Not available for scatter charts of non-adjacent table columns.
- -NoHeader SwitchParameter
- Treat the first row of Range as data rather than column headers.
- -PassThru SwitchParameter
- Return the native ExcelChart.
- -Preset ExcelDashboardChartPreset
- Dashboard appearance preset from the native Excel chart owner.
- Possible values:
Comparison,Trend,Contribution,CompactComparison - -Range String
- Bounded A1 range containing categories followed by value columns.
- -Sheet OfficeSheetSelector
- Sheet name, one-based position or an existing sheet belonging to Document.
- -Style Int32
- Built-in chart style identifier.
- -Title String
- Chart title.
- -Type OfficeChartType
- Shared chart family. Bubble requires the separate native bubble-data contract.
- Possible values:
ColumnClustered,Column,ColumnStacked,ColumnStacked100,BarClustered,Bar,BarStacked,BarStacked100,Line,LineStacked,LineStacked100,Area,AreaStacked,AreaStacked100,Scatter,Radar,Pie,Doughnut,Bubble,Column3DClustered,Column3DStacked,Column3DStacked100,Bar3DClustered,Bar3DStacked,Bar3DStacked100,Line3D,Area3D,Area3DStacked,Area3DStacked100,Pie3D,PieOfPie,BarOfPie,Stock,Surface,SurfaceWireframe,SurfaceContour,Funnel,Waterfall,BoxWhisker,Treemap,SurfaceContourWireframe,Sunburst - -Width OfficeLength
- Chart width; defaults to 640 pixels. Bare numbers mean points.
- -Category String
- Category column; defaults to the first table column.
- -Table String
- Name or display name of a table on the selected worksheet.
- -Value String[]
- Value columns in series order; defaults to all numeric table columns except Category.
- -InputObject Object
- Objects or tabular input to write as a table and chart.
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.