SparklineCollection.Add

SparklineCollection.Add method

Add a sparkline.

public int Add(string dataRange, int row, int column)
ParameterTypeDescription
dataRangeStringSpecifies the new data range of the sparkline.
rowInt32The row index of the location.
columnInt32The column index of the location.

Examples

using System;
using Aspose.Cells;
using Aspose.Cells.Charts;

namespace AsposeCellsExamples
{
    public class SparklineCollectionMethodAddWithStringInt32Int32Demo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            
            // Access first worksheet
            Worksheet worksheet = workbook.Worksheets[0];

            // Add some sample data
            for (int i = 0; i < 12; i++)
            {
                worksheet.Cells[4, 3 + i].PutValue(i + 1);
            }

            // Create a sparkline group
            int groupIndex = worksheet.SparklineGroups.Add(SparklineType.Line);
            SparklineGroup group = worksheet.SparklineGroups[groupIndex];

            // Add sparkline with data range and location
            int sparklineIndex = group.Sparklines.Add("D5:O5", 4, 15);

            // Save the workbook
            workbook.Save("output.xlsx");
        }
    }
}

See Also