Sparkline
| API | Description | Example |
|---|---|---|
| Range.SparklineGroups | Property that returns a sparkline group management object existing in the specified range | let range = instance.Application.ActiveSheet.Range("A1:B2"); let sparklineGroups = range.SparklineGroups; |
| SparklineGroups.Count | Property that returns the number of sparkline groups existing in the specified range | let range = instance.Application.ActiveSheet.Range("A1:B2"); let sparklineGroups = range.SparklineGroups; console.log(sparklineGroups.Count); |
| SparklineGroups.Item | Function that returns a sparkline group object at a specific index | let range = instance.Application.ActiveSheet.Range("A1:B2"); let sparklineGroups = range.SparklineGroups; let sparklineGroup = sparklineGroups.Item(1); |
| SparklineGroup.Count | Property that returns the number of sparklines within the sparkline group | let range = instance.Application.ActiveSheet.Range("A1:B2"); let sparklineGroup = range.SparklineGroups.Item(1); console.log(sparklineGroup.Count); |
| SparklineGroup.Location | Property that returns or changes the range object corresponding to the sparkline group location | let 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.SourceData | Property that returns or changes the string corresponding to the source data range of the sparkline group | let 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.Type | Property that returns or changes the type of the sparkline group | let range = instance.Application.ActiveSheet.Range("A1:B2"); let sparklineGroup = range.SparklineGroups.Item(1); console.log(sparklineGroup.Type); sparklineGroup.Type = instance.Enums.XlSparkType.xlSparkColumnStacked100; |
| SparklineGroup.Item | Function that returns a sparkline object at a specific index | let range = instance.Application.ActiveSheet.Range("A1:B2"); let sparklineGroup = range.SparklineGroups.Item(1); let sparkline = sparklineGroup.Item(1); |
| Sparkline.Location | Property that returns or changes the range object corresponding to the sparkline location | let 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.SourceData | Property that returns or changes the string corresponding to the source data range of the sparkline | let 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.ModifyLocation | Function that changes the location of the sparkline | let 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.ModifySourceData | Function that changes the source data range of the sparkline | let range = instance.Application.ActiveSheet.Range("A1:B2"); let sparklineGroup = range.SparklineGroups.Item(1); let sparkline = sparklineGroup.Item(1); sparkline.ModifySourceData("C1:D2"); |
| SparklineGroup.Delete | Function that removes the sparkline group | let range = instance.Application.ActiveSheet.Range("A1:B2"); let sparklineGroup = range.SparklineGroups.Item(1); sparklineGroup.Delete(); |
| SparklineGroup.Modify | Function that changes the sparkline group location and source data range | let 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.ModifyLocation | Function that changes the sparkline group location | let 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.ModifySourceData | Function that changes the sparkline group source data range | let range = instance.Application.ActiveSheet.Range("A1:B2"); let sparklineGroup = range.SparklineGroups.Item(1); sparklineGroup.ModifySourceData("C1:D2"); |
| SparklineGroups.Add | Function 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.Clear | Function that removes sparklines in the specified range | 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"); target.SparklineGroups.Add( instance.Enums.XlSparkType.xlSparkLine, activeSheet.Name + "!A1:B2"); target.SparklineGroups.Clear(); // Remove only the sparkline in cell D1 |
| SparklineGroups.ClearGroups | Function that removes both sparklines and their groups in the specified range | 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"); target.SparklineGroups.Add( instance.Enums.XlSparkType.xlSparkLine, activeSheet.Name + "!A1:B2"); target.SparklineGroups.ClearGroups(); // Remove sparklines in cells D1 and D2 |
| SparklineGroups.Group | Function that groups a cell’s sparkline into the specified sparkline group range | 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"); 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.Ungroup | Function that ungroups sparkline groups in the specified range | 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"); 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 |
Related Features
Visualization Tools , Chart Creation and Editing , Insert Shapes and Images