SeriesCollection

Inheritance: java.lang.Object, com.aspose.cells.CollectionBase

public class SeriesCollection extends CollectionBase

Encapsulates a collection of 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");

Methods

MethodDescription
add(Object o)Adds an item to the CollectionBase instance.
add(String area, boolean isVertical)Adds the Series collection to a chart.
add(String area, boolean isVertical, boolean checkLabels)Adds the Series collection to a chart.
addR1C1(String area, boolean isVertical)Adds the Series collection to a chart.
changeSeriesOrder(int sourceIndex, int destIndex)Directly changes the orders of the two series.
clear()Clears the collection
contains(Object o)Return whether instance contains this object
equals(Object arg0)
get(int index)Gets the Series element at the specified index.
getCategoryData()Gets the range of category Axis values.
getClass()
getCount()Gets the number of elements contained in the CollectionBase instance.
getSecondCategoryData()Gets the range of second category Axis values.
getSeriesByOrder(int order)Gets the Series element by order.
hashCode()
indexOf(Object o)Determines the index of a specific item in the CollectionBase instance.
isColorVaried()Represents if the color of points is varied.
iterator()Returns an enumerator that iterates through the CollectionBase instance.
notify()
notifyAll()
removeAt(int index)Remove at a series at the specific index.
setCategoryData(String value)Sets the range of category Axis values.
setColorVaried(boolean value)Represents if the color of points is varied.
setSecondCategoryData(String value)Sets the range of second category Axis values.
setSeriesNames(int startIndex, String area, boolean isVertical)Sets the name of all the serieses in the chart.
swapSeries(int sourceIndex, int destIndex)Directly changes the orders of the two series.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

add(Object o)

public int add(Object o)

Adds an item to the CollectionBase instance.

Parameters:

ParameterTypeDescription
ojava.lang.ObjectThe Object to add to the CollectionBase instance.

Returns: int - The position into which the new element was inserted.

add(String area, boolean isVertical)

public int add(String area, boolean isVertical)

Adds the Series collection to a chart.

Remarks

If set data on contiguous cells, use colon to seperate them.For example, $C$2:$C$5.

If set data on non contiguous cells, use comma to seperate them.For example: ($C$2,$D$5).

Parameters:

ParameterTypeDescription
areajava.lang.StringSpecifies values from which to plot the data series
isVerticalbooleanSpecifies whether to plot the series from a range of cell values by row or by column.

Returns: int - Return the first index of the added ASeries in the NSeries.

add(String area, boolean isVertical, boolean checkLabels)

public int add(String area, boolean isVertical, boolean checkLabels)

Adds the Series collection to a chart.

Remarks

If set data on contiguous cells, use colon to seperate them.For example, $C$2:$C$5.

If set data on non contiguous cells, use comma to seperate them.For example, ($C$2,$D$5).

Parameters:

ParameterTypeDescription
areajava.lang.StringSpecifies values from which to plot the data series
isVerticalbooleanSpecifies whether to plot the series from a range of cell values by row or by column.
checkLabelsbooleanIndicates whether the range contains series’s name

Returns: int - Return the first index of the added ASeries in the NSeries.

addR1C1(String area, boolean isVertical)

public int addR1C1(String area, boolean isVertical)

Adds the Series collection to a chart.

Remarks

If set data on contiguous cells, use colon to seperate them.For example, R[1]C[1]:R[3]C[2].

If set data on contiguous cells, use comma to seperate them.For example,(R[1]C[1],R[3]C[2]).

Parameters:

ParameterTypeDescription
areajava.lang.StringSpecifies values from which to plot the data series
isVerticalbooleanSpecifies whether to plot the series from a range of cell values by row or by column.

Returns: int - Return the first index of the added ASeries in the NSeries.

changeSeriesOrder(int sourceIndex, int destIndex)

public void changeSeriesOrder(int sourceIndex, int destIndex)

Directly changes the orders of the two series.

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.

Parameters:

ParameterTypeDescription
sourceIndexintThe current index
destIndexintThe dest index

clear()

public void clear()

Clears the collection

contains(Object o)

public boolean contains(Object o)

Return whether instance contains this object

Parameters:

ParameterTypeDescription
ojava.lang.Objecttest object

Returns: boolean - Whether instance contains this object

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

get(int index)

public Series get(int index)

Gets the Series element at the specified index.

Parameters:

ParameterTypeDescription
indexintThe zero based index of the element.

Returns: Series - The element at the specified index.

getCategoryData()

public String getCategoryData()

Gets the range of category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}").

Returns: java.lang.String

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getCount()

public int getCount()

Gets the number of elements contained in the CollectionBase instance.

Returns: int - The number of elements contained in the CollectionBase instance.

getSecondCategoryData()

public String getSecondCategoryData()

Gets the range of second category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}"). Only effects when some ASerieses plot on the second axis.

Returns: java.lang.String

getSeriesByOrder(int order)

public Series getSeriesByOrder(int order)

Gets the Series element by order.

Parameters:

ParameterTypeDescription
orderintThe order of series

Returns: Series - The element series

hashCode()

public native int hashCode()

Returns: int

indexOf(Object o)

public int indexOf(Object o)

Determines the index of a specific item in the CollectionBase instance.

Parameters:

ParameterTypeDescription
ojava.lang.ObjectDetermines the index of a specific item in the CollectionBase instance.

Returns: int - The index of value if found in the list; otherwise, -1.

isColorVaried()

public boolean isColorVaried()

Represents if the color of points is varied.

Returns: boolean

iterator()

public Iterator iterator()

Returns an enumerator that iterates through the CollectionBase instance.

Returns: java.util.Iterator - An iterator for the CollectionBase instance.

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

removeAt(int index)

public void removeAt(int index)

Remove at a series at the specific index.

Parameters:

ParameterTypeDescription
indexintThe index.

setCategoryData(String value)

public void setCategoryData(String value)

Sets the range of category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}").

Parameters:

ParameterTypeDescription
valuejava.lang.String

setColorVaried(boolean value)

public void setColorVaried(boolean value)

Represents if the color of points is varied.

Parameters:

ParameterTypeDescription
valueboolean

setSecondCategoryData(String value)

public void setSecondCategoryData(String value)

Sets the range of second category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}"). Only effects when some ASerieses plot on the second axis.

Parameters:

ParameterTypeDescription
valuejava.lang.String

setSeriesNames(int startIndex, String area, boolean isVertical)

public void setSeriesNames(int startIndex, String area, boolean isVertical)

Sets the name of all the serieses in the chart.

Remarks

If the start index is larger than the count of the serieses, it will return and do nothing.

If set data on contiguous cells, use colon to seperate them.For example, $C$2:$C$5.

If set data on contiguous cells, use comma to seperate them.For example, ($C$2,$D$5).

Parameters:

ParameterTypeDescription
startIndexintThe index of the first series which you want to set the name.
areajava.lang.StringSpecifies the area for the series name.
isVerticalboolean>Specifies whether to plot the series from a range of cell values by row or by column.

swapSeries(int sourceIndex, int destIndex)

public void swapSeries(int sourceIndex, int destIndex)

Directly changes the orders of the two series.

Parameters:

ParameterTypeDescription
sourceIndexintThe current index
destIndexintThe dest index

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int