public class SeriesCollection extends CollectionBase
Series objects.
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);
//Adding a sample value to "A1" cell
worksheet.getCells().get("A1").putValue(50);
//Adding a sample value to "A2" cell
worksheet.getCells().get("A2").putValue(100);
//Adding a sample value to "A3" cell
worksheet.getCells().get("A3").putValue(150);
//Adding a sample value to "A4" cell
worksheet.getCells().get("A4").putValue(200);
//Adding a sample value to "B1" cell
worksheet.getCells().get("B1").putValue(60);
//Adding a sample value to "B2" cell
worksheet.getCells().get("B2").putValue(32);
//Adding a sample value to "B3" cell
worksheet.getCells().get("B3").putValue(50);
//Adding a sample value to "B4" cell
worksheet.getCells().get("B4").putValue(40);
//Adding a sample value to "C1" cell as category data
worksheet.getCells().get("C1").putValue("Q1");
//Adding a sample value to "C2" cell as category data
worksheet.getCells().get("C2").putValue("Q2");
//Adding a sample value to "C3" cell as category data
worksheet.getCells().get("C3").putValue("Y1");
//Adding a sample value to "C4" cell as category data
worksheet.getCells().get("C4").putValue("Y2");
//Adding a chart to the worksheet
int chartIndex = worksheet.getCharts().add(ChartType.COLUMN, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.getCharts().get(chartIndex);
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.getNSeries().add("A1:B4", true);
//Setting the data source for the category data of NSeries
chart.getNSeries().setCategoryData("C1:C4");
//Saving the Excel file
workbook.save("book1.xls");
| Modifier and Type | Method and Description |
|---|---|
int |
add(java.lang.String area,
boolean isVertical)
Adds the
Series collection to a chart. |
int |
add(java.lang.String area,
boolean isVertical,
boolean checkLabels)
Adds the
Series collection to a chart. |
int |
addR1C1(java.lang.String area,
boolean isVertical)
Adds the
Series collection to a chart. |
void |
changeColors(int type)
Set Monochromatic Palette for chart series.
|
void |
changeSeriesOrder(int sourceIndex,
int destIndex)
Deprecated.
Use SeriesCollection.SwapSeries property, instead.
|
void |
clear()
Clears the collection
|
Series |
get(int index)
Gets the
Series element at the specified index. |
java.lang.String |
getCategoryData()
Gets the range of category Axis values.
|
java.lang.String |
getSecondCategoryData()
Gets the range of second category Axis values.
|
Series |
getSeriesByOrder(int order)
Gets the
Series element by order. |
boolean |
isColorVaried()
Represents if the color of points is varied.
|
void |
removeAt(int index)
Remove at a series at the specific index.
|
void |
setCategoryData(java.lang.String value)
Sets the range of category Axis values.
|
void |
setColorVaried(boolean value)
Represents if the color of points is varied.
|
void |
setSecondCategoryData(java.lang.String value)
Sets the range of second category Axis values.
|
void |
setSeriesNames(int startIndex,
java.lang.String area,
boolean isVertical)
Sets the name of all the serieses in the chart.
|
void |
swapSeries(int sourceIndex,
int destIndex)
Directly changes the orders of the two series.
|
public Series get(int index)
Series element at the specified index.get in class CollectionBaseindex - The zero based index of the element.public Series getSeriesByOrder(int order)
Series element by order.order - The order of seriespublic void removeAt(int index)
removeAt in class CollectionBaseindex - The index.public java.lang.String getCategoryData()
public void setCategoryData(java.lang.String value)
public java.lang.String getSecondCategoryData()
public void setSecondCategoryData(java.lang.String value)
public void changeSeriesOrder(int sourceIndex,
int destIndex)
Remarks
NOTE: This method is now obsolete. Instead, please use SeriesCollection.SwapSeries method. This method will be removed 12 months later since June 2024. Aspose apologizes for any inconvenience you may have experienced.sourceIndex - The current indexdestIndex - The dest indexpublic void swapSeries(int sourceIndex,
int destIndex)
sourceIndex - The current indexdestIndex - The dest indexpublic void setSeriesNames(int startIndex,
java.lang.String area,
boolean isVertical)
Remarks
startIndex - The index of the first series which you want to set the name.area - Specifies the area for the series name.isVertical - >Specifies whether to plot the series from a range of cell values by row or by column.public int addR1C1(java.lang.String area,
boolean isVertical)
Series collection to a chart.
Remarks
area - Specifies values from which to plot the data seriesisVertical - Specifies whether to plot the series from a range of cell values by row or by column.public int add(java.lang.String area,
boolean isVertical)
Series collection to a chart.
Remarks
area - Specifies values from which to plot the data seriesisVertical - Specifies whether to plot the series from a range of cell values by row or by column.public int add(java.lang.String area,
boolean isVertical,
boolean checkLabels)
Series collection to a chart.
Remarks
area - Specifies values from which to plot the data seriesisVertical - Specifies whether to plot the series from a range of cell values by row or by column.checkLabels - Indicates whether the range contains series's namepublic boolean isColorVaried()
public void setColorVaried(boolean value)
public void clear()
clear in class CollectionBasepublic void changeColors(int type)
type - ChartColorPaletteType. The Monochromatic Type.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.