Aspose::Cells::Charts::SeriesCollection class

SeriesCollection class

Encapsulates a collection of Series objects.

class SeriesCollection

Methods

MethodDescription
Add(const U16String& area, bool isVertical)Adds the Series collection to a chart.
Add(const char16_t* area, bool isVertical)Adds the Series collection to a chart.
Add(const U16String& area, bool isVertical, bool checkLabels)Adds the Series collection to a chart.
Add(const char16_t* area, bool isVertical, bool checkLabels)Adds the Series collection to a chart.
AddR1C1(const U16String& area, bool isVertical)Adds the Series collection to a chart.
AddR1C1(const char16_t* area, bool isVertical)Adds the Series collection to a chart.
ChangeSeriesOrder(int32_t sourceIndex, int32_t destIndex)(Deprecated) Directly changes the orders of the two series.
Clear()Clears the collection.
Get(int32_t index)Gets the Series element at the specified index.
GetCategoryData()Gets or 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}").
GetCount()
GetSecondCategoryData()Gets or 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.
GetSeriesByOrder(int32_t order)Gets the Series element by order.
IsColorVaried()Represents if the color of points is varied.
IsNull() constChecks whether the implementation object is nullptr.
explicit operator bool() constoperator bool()
operator=(const SeriesCollection& src)operator=
RemoveAt(int32_t index)Remove at a series at the specific index.
SeriesCollection(SeriesCollection_Impl* impl)Constructs from an implementation object.
SeriesCollection(const SeriesCollection& src)Copy constructor.
SetCategoryData(const U16String& value)Gets or 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}").
SetCategoryData(const char16_t* value)Gets or 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}").
SetIsColorVaried(bool value)Represents if the color of points is varied.
SetSecondCategoryData(const U16String& value)Gets or 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.
SetSecondCategoryData(const char16_t* value)Gets or 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.
SetSeriesNames(int32_t startIndex, const U16String& area, bool isVertical)Sets the name of all the serieses in the chart.
SetSeriesNames(int32_t startIndex, const char16_t* area, bool isVertical)Sets the name of all the serieses in the chart.
SwapSeries(int32_t sourceIndex, int32_t destIndex)Directly changes the orders of the two series.
~SeriesCollection()Destructor.

Fields

FieldDescription
_implThe implementation object.

Examples

Aspose::Cells::Startup();
//Instantiating a Workbook object
Workbook 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(u"A1").PutValue(50);
//Adding a sample value to "A2" cell
worksheet.GetCells().Get(u"A2").PutValue(100);
//Adding a sample value to "A3" cell
worksheet.GetCells().Get(u"A3").PutValue(150);
//Adding a sample value to "A4" cell
worksheet.GetCells().Get(u"A4").PutValue(200);
//Adding a sample value to "B1" cell
worksheet.GetCells().Get(u"B1").PutValue(60);
//Adding a sample value to "B2" cell
worksheet.GetCells().Get(u"B2").PutValue(32);
//Adding a sample value to "B3" cell
worksheet.GetCells().Get(u"B3").PutValue(50);
//Adding a sample value to "B4" cell
worksheet.GetCells().Get(u"B4").PutValue(40);
//Adding a sample value to "C1" cell as category data
worksheet.GetCells().Get(u"C1").PutValue(u"Q1");
//Adding a sample value to "C2" cell as category data
worksheet.GetCells().Get(u"C2").PutValue(u"Q2");
//Adding a sample value to "C3" cell as category data
worksheet.GetCells().Get(u"C3").PutValue(u"Y1");
//Adding a sample value to "C4" cell as category data
worksheet.GetCells().Get(u"C4").PutValue(u"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(u"A1:B4", true);
//Setting the data source for the category data of NSeries
chart.GetNSeries().SetCategoryData(u"C1:C4");
//Saving the Excel file
workbook.Save(u"book1.xls");

Aspose::Cells::Cleanup();

See Also