Cmdlet
Set-OfficeExcelChartTrendline
Adds or replaces a series trendline.
Syntax
Set-OfficeExcelChartTrendline
[-Backward <Double>]
[-Chart] <ExcelChart>
[-DisplayEquation]
[-DisplayRSquared]
[-Forward <Double>]
-Index <Int32>
[-Intercept <Double>]
[-LineColor <OfficeColor>]
[-LineWidth <OfficeLength>]
[-Order <Int32>]
[-PassThru]
[-Period <Int32>]
[-Type <OfficeChartTrendlineType>]
[<CommonParameters>]#Parameter set:
IndexSet-OfficeExcelChartTrendline
[-Backward <Double>]
[-CaseSensitive]
[-Chart] <ExcelChart>
[-DisplayEquation]
[-DisplayRSquared]
[-Forward <Double>]
[-Intercept <Double>]
[-LineColor <OfficeColor>]
[-LineWidth <OfficeLength>]
-Name <String>
[-Order <Int32>]
[-PassThru]
[-Period <Int32>]
[-Type <OfficeChartTrendlineType>]
[<CommonParameters>]#Parameter set:
NameExamples
Add a linear trendline
New-OfficeExcel -Path .\Reports\Growth.xlsx {
ExcelSheet 'Users' {
ExcelChart -InputObject (Import-OfficeCsv -Path .\Data\Monthly-Users.csv) -Category Month -Value ActiveUsers -Type Line -Address A1 -PassThru | ExcelChartTrendline -Index 1 -Type Linear
}
}Adds a straight trendline to the first series.
Project storage growth
New-OfficeExcel -Path .\Reports\Storage-Forecast.xlsx {
ExcelSheet 'Storage' {
$chart = ExcelChart -InputObject (Import-OfficeCsv -Path .\Data\Storage-Used.csv) -Category Month -Value UsedTB -Type Line -Address A1 -Title 'Storage used (TB)' -PassThru
ExcelChartTrendline -Chart $chart -Name UsedTB -Type Linear -Forward 3 -DisplayRSquared
}
}Fits a trendline to monthly storage use, projects it three months forward and shows the R-squared value on the chart.
Parameters
- -Backward Double
- Backward forecast units.
- -Chart ExcelChart
- Chart to update.
- -DisplayEquation SwitchParameter
- Display the trendline equation.
- -DisplayRSquared SwitchParameter
- Display the R-squared value.
- -Forward Double
- Forward forecast units.
- -Index Int32
- One-based index identifying the target item.
- -Intercept Double
- Trendline intercept.
- -LineColor OfficeColor
- Trendline line color. Named colors and hexadecimal values are accepted.
- -LineWidth OfficeLength
- Physical line width; numbers are interpreted as points.
- -Order Int32
- Polynomial order.
- -PassThru SwitchParameter
- Emits the native result after the operation.
- -Period Int32
- Moving-average period.
- -Type OfficeChartTrendlineType
- Trendline type.
- Possible values:
Exponential,Linear,Logarithmic,MovingAverage,Polynomial,Power - -CaseSensitive SwitchParameter
- Matches names and text using ordinal case sensitivity. Omission ignores case.
- -Name String
- Named range name.
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.