Skip to main content

Sparkline

APIDescriptionExample
Range.SparklineGroupsProperty that returns a sparkline group management object existing in the specified rangelet range = instance.Application.ActiveSheet.Range("A1:B2");

let sparklineGroups = range.SparklineGroups;
SparklineGroups.CountProperty that returns the number of sparkline groups existing in the specified rangelet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroups = range.SparklineGroups;

console.log(sparklineGroups.Count);
SparklineGroups.ItemFunction that returns a sparkline group object at a specific indexlet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroups = range.SparklineGroups;

let sparklineGroup = sparklineGroups.Item(1);
SparklineGroup.CountProperty that returns the number of sparklines within the sparkline grouplet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);

console.log(sparklineGroup.Count);
SparklineGroup.LocationProperty that returns or changes the range object corresponding to the sparkline group locationlet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);

let location = sparklineGroup.Location;

let target = instance.Application.ActiveSheet.Range("C1:D2");
sparklineGroup.Location = target;
SparklineGroup.SourceDataProperty that returns or changes the string corresponding to the source data range of the sparkline grouplet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);

console.log(sparklineGroup.SourceData); // A1:B2 string is output to console
sparklineGroup.SourceData = "C1:D2";
SparklineGroup.TypeProperty that returns or changes the type of the sparkline grouplet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);

console.log(sparklineGroup.Type);
sparklineGroup.Type = instance.Enums.XlSparkType.xlSparkColumnStacked100;
SparklineGroup.ItemFunction that returns a sparkline object at a specific indexlet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);

let sparkline = sparklineGroup.Item(1);
Sparkline.LocationProperty that returns or changes the range object corresponding to the sparkline locationlet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);
let sparkline = sparklineGroup.Item(1);

let location = sparkline.Location;

let target = instance.Application.ActiveSheet.Range("C1:D2");
sparkline.Location = target;
Sparkline.SourceDataProperty that returns or changes the string corresponding to the source data range of the sparklinelet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);
let sparkline = sparklineGroup.Item(1);

console.log(sparkline.SourceData); // A1:B2 string is output to console
sparkline.SourceData = "C1:D2";
Sparkline.ModifyLocationFunction that changes the location of the sparklinelet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);
let sparkline = sparklineGroup.Item(1);

let target = instance.Application.ActiveSheet.Range("C1:D2");
sparkline.ModifyLocation(target);
Sparkline.ModifySourceDataFunction that changes the source data range of the sparklinelet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);
let sparkline = sparklineGroup.Item(1);

sparkline.ModifySourceData("C1:D2");
SparklineGroup.DeleteFunction that removes the sparkline grouplet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);

sparklineGroup.Delete();
SparklineGroup.ModifyFunction that changes the sparkline group location and source data rangelet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);

let target = instance.Application.ActiveSheet.Range("C1:D2");
sparklineGroup.Modify(target, "C1:D2");
SparklineGroup.ModifyLocationFunction that changes the sparkline group locationlet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);

let target = instance.Application.ActiveSheet.Range("C1:D2");
sparklineGroup.ModifyLocation(target);
SparklineGroup.ModifySourceDataFunction that changes the sparkline group source data rangelet range = instance.Application.ActiveSheet.Range("A1:B2");
let sparklineGroup = range.SparklineGroups.Item(1);

sparklineGroup.ModifySourceData("C1:D2");
SparklineGroups.AddFunction that creates a sparkline group at the specified range
cf) The base range must match the number of rows or columns
let workbook = instance.Application.ActiveWorkbook;
let activeSheet = workbook.ActiveSheet;

let source = activeSheet.Range("A1:B2");
source.Value2 = [ [1, 2], [3, 4] ];

let target = activeSheet.Range("D1:D2"); target.SparklineGroups.Add(
instance.Enums.XlSparkType.xlSparkLine, activeSheet.Name + "!A1:B2");
SparklineGroups.ClearFunction that removes sparklines in the specified rangelet workbook = instance.Application.ActiveWorkbook;
let activeSheet = workbook.ActiveSheet;

let source = activeSheet.Range("A1:B2");
source.Value2 = [ [1, 2], [3, 4] ];

let target = activeSheet.Range("D1");
target.SparklineGroups.Add(
instance.Enums.XlSparkType.xlSparkLine, activeSheet.Name + "!A1:B2");

target.SparklineGroups.Clear(); // Remove only the sparkline in cell D1
SparklineGroups.ClearGroupsFunction that removes both sparklines and their groups in the specified rangelet workbook = instance.Application.ActiveWorkbook;
let activeSheet = workbook.ActiveSheet;

let source = activeSheet.Range("A1:B2");
source.Value2 = [ [1, 2], [3, 4] ];

let target = activeSheet.Range("D1");
target.SparklineGroups.Add(
instance.Enums.XlSparkType.xlSparkLine, activeSheet.Name + "!A1:B2");

target.SparklineGroups.ClearGroups(); // Remove sparklines in cells D1 and D2
SparklineGroups.GroupFunction that groups a cell’s sparkline into the specified sparkline group rangelet workbook = instance.Application.ActiveWorkbook;
let activeSheet = workbook.ActiveSheet;

let source = activeSheet.Range("A1:B2"); source.Value2 = [ [1, 2], [3, 4] ];

let target = activeSheet.Range("D1");
target.SparklineGroups.Add(
instance.Enums.XlSparkType.xlSparkLine, activeSheet.Name + "!A1:B1");

let other = activeSheet.Range("D2");
other.SparklineGroups.Add(
instance.Enums.XlSparkType.xlSparkColumn, activeSheet.Name + "!A2:B2");

let group = activeSheet.Range("D1:D2");
group.SparklineGroups.Group(other);
SparklineGroups.UngroupFunction that ungroups sparkline groups in the specified rangelet workbook = instance.Application.ActiveWorkbook;
let activeSheet = workbook.ActiveSheet;

let source = activeSheet.Range("A1:B2"); source.Value2 = [ [1, 2], [3, 4] ];

let target = activeSheet.Range("D1");
target.SparklineGroups.Add(
instance.Enums.XlSparkType.xlSparkLine, activeSheet.Name + "!A1:B2");

target.SparklineGroups.Ungroup();
target.SparklineGroups.ClearGroups(); // After ungrouping, removes only the sparkline in D1

Visualization Tools , Chart Creation and Editing , Insert Shapes and Images