View Single Post
Old 10-12-2008   #2 (permalink)
Kiron


 
 

Re: Problems creating trendlines in powershell-created excel chart

Trendlines()'s Add Method signature is:
http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

Add(Type, Order, Period, Forward, Backward, Intercept, DisplayEquation, DisplayRSquared, Name)

Need to add empty parenthesis to Trendlines though.

To call the method with all its arguments set the Order and Period to 2, they're the default anyway and 0 or $null won't work, but the Type could be set as xlPolynomial, you'd have to correct that like this:
# mind word wrap
$serie1Trend1 = $ac.SeriesCollection(1).Trendlines().Add(-4132,2,2,0,0,0,$True,$True,'Serie1Trend1')
$serie1Trend1.type = -4132

# or, create the trendline as xlLinear -default- and then
# adjust its properties
$serie1Trend1 = $ac.SeriesCollection(1).Trendlines().Add()
$serie1Trend1.DisplayEquation = $true
$serie1Trend1.DisplayRSquared = $true
$serie1Trend1.Name = 'myTL'

# another option
$serie1Trend1 = $ac.SeriesCollection(1).Trendlines().Add()
$serie1Trend1 | % {
$_.DisplayEquation = $true
$_.DisplayRSquared = $true
$_.Name = 'myTL'
}

--
Kiron
My System SpecsSystem Spec