Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficeExcelChart

Aliases: ExcelChart
Module
PSWriteOffice
Aliases
ExcelChart
Inputs
OfficeIMO.Excel.ExcelDocument System.Object
Outputs
OfficeIMO.Excel.ExcelChart

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>]
#
Parameter set: Range
Add-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>]
#
Parameter set: Table
Add-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>]
#
Parameter set: Data

Description

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 required
Single A1 cell anchoring the top-left corner of the chart.
-ColorStyle Int32 optional
Built-in chart color-style identifier.
-Document ExcelDocument optionalpipeline: True (ByValue)
Workbook to modify outside an Excel composition block.
-Height OfficeLength optional
Chart height; defaults to 360 pixels. Bare numbers mean points.
-NoCachedData SwitchParameter optional
Omit cached chart values. Not available for scatter charts of non-adjacent table columns.
-NoHeader SwitchParameter optionalsets: Range
Treat the first row of Range as data rather than column headers.
-PassThru SwitchParameter optional
Return the native ExcelChart.
-Preset ExcelDashboardChartPreset optional
Dashboard appearance preset from the native Excel chart owner.
Possible values: Comparison, Trend, Contribution, CompactComparison
-Range String requiredposition: 0sets: Range
Bounded A1 range containing categories followed by value columns.
-Sheet OfficeSheetSelector optional
Sheet name, one-based position or an existing sheet belonging to Document.
-Style Int32 optional
Built-in chart style identifier.
-Title String optional
Chart title.
-Type OfficeChartType optional
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 optional
Chart width; defaults to 640 pixels. Bare numbers mean points.
-Category String required in Datasets: Table, Data
Category column; defaults to the first table column.
-Table String requiredsets: Table
Name or display name of a table on the selected worksheet.
-Value String[] required in Datasets: Table, Data
Value columns in series order; defaults to all numeric table columns except Category.
-InputObject Object requiredpipeline: True (ByValue)sets: Data
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.