officefileapi-116978-excel-export-library-sparklines-how-to-create-sparklines.md
Worksheet sparklines are organized in groups. Each group contains one or more sparklines of the same type that share identical format settings and axis scaling options. To create a new group of sparklines, use the XlSparklineGroup constructor which requires the following parameters:
You do not have to create individual sparklines in a group, they are created automatically with this constructor. All created sparklines have the default XlSparklineType.Line type.
To add a sparkline group to the worksheet, use the Add method of the collection available with the XlSparklineGroup.Sparklines property, as illustrated in the code snippet below:
// Create a group of line sparklines.
XlSparklineGroup group = new XlSparklineGroup(XlCellRange.FromLTRB(1, 1, 4, 6), XlCellRange.FromLTRB(5, 1, 5, 6));
// Set the sparkline weight.
group.LineWeight = 1.25;
// Display data markers on the sparklines.
group.DisplayMarkers = true;
sheet.SparklineGroups.Add(group);
' Create a group of line sparklines.
Dim group As New XlSparklineGroup(XlCellRange.FromLTRB(1, 1, 4, 6), XlCellRange.FromLTRB(5, 1, 5, 6))
' Set the sparkline weight.
group.LineWeight = 1.25
' Display data markers on the sparklines.
group.DisplayMarkers = True
sheet.SparklineGroups.Add(group)
Note
If you create a sparkline group using the default parameterless constructor, the group does not contain sparklines. You should manually create a XlSparkline object and add it to the collection accessible with the XlSparklineGroup.Sparklines property.