Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficeExcelSparkline

Aliases: ExcelSparkline
Module
PSWriteOffice
Aliases
ExcelSparkline
Inputs
OfficeIMO.Excel.ExcelDocument

Adds sparklines to a worksheet.

Syntax

Add-OfficeExcelSparkline
[-AxisColor <OfficeColor>]
-DataRange <String>
[-Document <ExcelDocument>]
[-FirstColor <OfficeColor>]
[-HighColor <OfficeColor>]
[-LastColor <OfficeColor>]
-LocationRange <String>
[-LowColor <OfficeColor>]
[-MarkerColor <OfficeColor>]
[-NegativeColor <OfficeColor>]
[-PassThru]
[-SeriesColor <OfficeColor>]
[-Sheet <OfficeSheetSelector>]
[-ShowAxis]
[-ShowFirstLast]
[-ShowHighLow]
[-ShowMarkers]
[-ShowNegative]
[-Type <Line|Column|Stacked>]
[<CommonParameters>]
#
Parameter set: Default

Examples

Add line sparklines

Open-OfficeExcel -Path .\Reports\Budget-2027.xlsx {
    ExcelSheet 'Departments' {
        ExcelSparkline -DataRange B2:M20 -LocationRange N2:N20
    }
}

Draws a sparkline for each row of monthly figures in the column next to them.

Show weekly trends with high and low points

New-OfficeExcel -Path .\Reports\Site-Incidents.xlsx {
    ExcelSheet 'Incidents' {
        ExcelTable (Import-OfficeCsv -Path .\Data\Incidents-By-Week.csv) -Name Incidents
        ExcelSparkline -DataRange B2:M9 -LocationRange N2:N9 -Type Column -ShowHighLow
    }
}

Adds column sparklines with the highest and lowest weeks marked, so each site's pattern is visible at a glance.

Parameters

-AxisColor OfficeColor optional
Axis color. Named colors and hexadecimal values are accepted.
-DataRange String required
A1 range containing source data (e.g., "B2:M2").
-Document ExcelDocument optionalpipeline: True (ByValue)
Workbook to operate on outside the DSL context.
-FirstColor OfficeColor optional
First point color. Named colors and hexadecimal values are accepted.
-HighColor OfficeColor optional
High point color. Named colors and hexadecimal values are accepted.
-LastColor OfficeColor optional
Last point color. Named colors and hexadecimal values are accepted.
-LocationRange String required
A1 range where the sparklines will be placed (e.g., "N2:N2").
-LowColor OfficeColor optional
Low point color. Named colors and hexadecimal values are accepted.
-MarkerColor OfficeColor optional
Markers color. Named colors and hexadecimal values are accepted.
-NegativeColor OfficeColor optional
Negative point color. Named colors and hexadecimal values are accepted.
-PassThru SwitchParameter optional
Emit the worksheet after adding sparklines.
-SeriesColor OfficeColor optional
Series color. Named colors and hexadecimal values are accepted.
-Sheet OfficeSheetSelector optional
Worksheet name when using Document.
-ShowAxis SwitchParameter optional
Show axis.
-ShowFirstLast SwitchParameter optional
Show first/last points.
-ShowHighLow SwitchParameter optional
Show high/low points.
-ShowMarkers SwitchParameter optional
Show markers for each point.
-ShowNegative SwitchParameter optional
Show negative points.
-Type ExcelSparklineType optional
Sparkline type (Line, Column, WinLoss).
Possible values: Line, Column, Stacked

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.