public class TrendlineCollection extends CollectionBase
Trendline objects for the specified data series.
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
worksheet.getCells().get("A1").putValue(50);
worksheet.getCells().get("A2").putValue(100);
worksheet.getCells().get("A3").putValue(150);
worksheet.getCells().get("A4").putValue(200);
worksheet.getCells().get("B1").putValue(60);
worksheet.getCells().get("B2").putValue(32);
worksheet.getCells().get("B3").putValue(50);
worksheet.getCells().get("B4").putValue(40);
//Adding a chart to the worksheet
int chartIndex = workbook.getWorksheets().get(0).getCharts().add(ChartType.COLUMN, 3, 3, 15, 10);
Chart chart = workbook.getWorksheets().get(0).getCharts().get(chartIndex);
chart.getNSeries().add("A1:a3", true);
chart.getNSeries().get(0).getTrendLines().add(TrendlineType.LINEAR, "MyTrendLine");
Trendline line = chart.getNSeries().get(0).getTrendLines().get(0);
line.setDisplayEquation(true);
line.setDisplayRSquared(true);
line.setColor(Color.getRed());
| Modifier and Type | Method and Description |
|---|---|
int |
add(int type)
Adds a
Trendline object to this collection with specified type. |
int |
add(int type,
java.lang.String name)
Adds a
Trendline object to this collection with specified type and name. |
Trendline |
get(int index)
Gets a
Trendline object by its index. |
public int add(int type)
Trendline object to this collection with specified type.type - TrendlineType. Trendline type.Trendline object index.public int add(int type,
java.lang.String name)
Trendline object to this collection with specified type and name.type - TrendlineType. Trendline type.name - Trendline name.Trendline object index.public Trendline get(int index)
Trendline object by its index.get in class CollectionBaseindex - Specified position index.See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.