Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
Row

SparklineCollection.Add(Int32, Int32, CellRange) Method

Creates a new sparkline and adds it to the collection.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v20.2.Core.dll

Declaration

Sparkline Add(
    int rowIndex,
    int columnIndex,
    CellRange dataRange
)

Parameters

Name Type Description
rowIndex Int32

An integer that is the zero-based index of the row where the new sparkline should be located.

columnIndex Int32

An integer that is the zero-based index of the column where the new sparkline should be located.

dataRange CellRange

A CellRange object that contains the source data for the sparkline.

Returns

Type Description
Sparkline

A Sparkline object that specifies the new sparkline.

Remarks

All sparklines in a worksheet are organized in groups. Each sparkline group includes one or more sparklines stored within the SparklineCollection collection accessible using the SparklineGroup.Sparklines property. Use the collection’s Add method to add a new sparkline to the existing sparkline group, as shown in the example below.

Worksheet worksheet = workbook.Worksheets["SparklineExamples"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a group of line sparklines.
SparklineGroup quarterlyGroup = worksheet.SparklineGroups.Add(worksheet["G4:G6"], worksheet["C4:F4,C5:F5,C6:F6"], SparklineGroupType.Line);
// Add one more sparkline to the existing group.
quarterlyGroup.Sparklines.Add(6, 6, worksheet["C7:F7"]);

// Display a column sparkline in the total cell.
SparklineGroup totalGroup = worksheet.SparklineGroups.Add(worksheet["G8"], worksheet["C8:F8"], SparklineGroupType.Column);

To remove a sparkline from the collection, use the SparklineCollection.Remove or SparklineCollection.RemoveAt method.

See Also