TrendlineCollection

TrendlineCollection class

Represents a collection of all the Trendline objects for the specified data series.

public class TrendlineCollection : CollectionBase<Trendline>

Properties

Name Description
Capacity { get; set; }
Count { get; }
Item { get; } Gets a object by its index.
Item { get; set; }

Methods

Name Description
Add(TrendlineType) Adds a object to this collection with specified type.
Add(TrendlineType, string) Adds a object to this collection with specified type and name.
BinarySearch(Trendline)
BinarySearch(Trendline, IComparer<Trendline>)
BinarySearch(int, int, Trendline, IComparer<Trendline>)
Clear()
Contains(Trendline)
CopyTo(Trendline[])
CopyTo(Trendline[], int)
CopyTo(int, Trendline[], int, int)
Exists(Predicate<Trendline>)
Find(Predicate<Trendline>)
FindAll(Predicate<Trendline>)
FindIndex(Predicate<Trendline>)
FindIndex(int, Predicate<Trendline>)
FindIndex(int, int, Predicate<Trendline>)
FindLast(Predicate<Trendline>)
FindLastIndex(Predicate<Trendline>)
FindLastIndex(int, Predicate<Trendline>)
FindLastIndex(int, int, Predicate<Trendline>)
GetEnumerator()
IndexOf(Trendline)
IndexOf(Trendline, int)
IndexOf(Trendline, int, int)
LastIndexOf(Trendline)
LastIndexOf(Trendline, int)
LastIndexOf(Trendline, int, int)
RemoveAt(int)

Examples

[C#]

//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
worksheet.Cells["A1"].PutValue(50);
worksheet.Cells["A2"].PutValue(100);
worksheet.Cells["A3"].PutValue(150);
worksheet.Cells["A4"].PutValue(200);
worksheet.Cells["B1"].PutValue(60);
worksheet.Cells["B2"].PutValue(32);
worksheet.Cells["B3"].PutValue(50);
worksheet.Cells["B4"].PutValue(40);

//Adding a chart to the worksheet
int chartIndex = workbook.Worksheets[0].Charts.Add(ChartType.Column, 3, 3, 15, 10);
Chart chart = workbook.Worksheets[0].Charts[chartIndex];
chart.NSeries.Add("A1:a3", true);
chart.NSeries[0].TrendLines.Add(TrendlineType.Linear, "MyTrendLine");
Trendline line = chart.NSeries[0].TrendLines[0];
line.DisplayEquation = true;
line.DisplayRSquared = true;
line.Color = Color.Red;

[Visual Basic]

'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Excel object
Dim sheetIndex As Int32 = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
worksheet.Cells("A1").PutValue(50)
worksheet.Cells("A2").PutValue(100)
worksheet.Cells("A3").PutValue(150)
worksheet.Cells("A4").PutValue(200)
worksheet.Cells("B1").PutValue(60)
worksheet.Cells("B2").PutValue(32)
worksheet.Cells("B3").PutValue(50)
worksheet.Cells("B4").PutValue(40)

'Adding a chart to the worksheet
Dim chartIndex As Integer =  workbook.Worksheets(0).Charts.Add(ChartType.Column,3,3,15,10) 
Dim chart As Chart =  workbook.Worksheets(0).Charts(chartIndex) 
chart.NSeries.Add("A1:a3", True)
chart.NSeries(0).TrendLines.Add(TrendlineType.Linear, "MyTrendLine")
Dim line As Trendline =  chart.NSeries(0).TrendLines(0) 
line.DisplayEquation = True
line.DisplayRSquared = True
line.Color = Color.Red

See Also