Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeExcelChart

Module
PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelChart

Applies a built-in style and color preset to a chart.

Syntax

Set-OfficeExcelChart
[-Chart] <ExcelChart>
[-ColorStyle <Int32>]
[-PassThru]
[-Style <Int32>]
[<CommonParameters>]
#
Parameter set: Default

Examples

Apply a chart style

New-OfficeExcel -Path .\Reports\Regions.xlsx {
    ExcelSheet 'Summary' {
        ExcelTable (Import-OfficeCsv -Path .\Data\Region-Revenue.csv) -Name RegionSummary
        ExcelChart -Table RegionSummary -Address F2 -Type Column -PassThru | Set-OfficeExcelChart -Style 3
    }
}

Applies built-in chart style 3 to a chart returned by ExcelChart.

Give a dashboard chart a monochrome palette

New-OfficeExcel -Path .\Reports\Operations.xlsx {
    ExcelSheet 'Dashboard' {
        $chart = ExcelChart -InputObject (Import-OfficeCsv -Path .\Data\Site-Uptime.csv) -Category Site -Value Uptime -Address A1 -Type Column -PassThru
        Set-OfficeExcelChart -Chart $chart -Style 6 -ColorStyle 14
    }
}

Uses a built-in style and colour preset for a chart that sits on a branded dashboard.

Parameters

-Chart ExcelChart requiredposition: 0pipeline: True (ByValue)
Chart to update.
-ColorStyle Int32 optional
Built-in chart color-style identifier.
-PassThru SwitchParameter optional
Emits the native result after the operation.
-Style Int32 optional
Built-in chart style identifier.

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.