Skip to main content
All docs
V25.1
  • Row

    SparklineCollection.Add(Int32, Int32, CellRange) Method

    Creates a new sparkline and adds it to the collection.

    Namespace: DevExpress.Spreadsheet

    Assembly: DevExpress.Spreadsheet.v25.1.Core.dll

    NuGet Package: DevExpress.Spreadsheet.Core

    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.

    The following code snippet uses the collection’s Add method to add a new sparkline to the existing sparkline group:

    View Example

    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.

    The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Add(Int32, Int32, CellRange) method.

    Note

    The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

    See Also