[]
        
(Showing Draft Content)

ISparkline

Interface ISparkline


public interface ISparkline
Represents a single sparkline.

An ISparkline defines one sparkline item in a worksheet, including the cell that displays the sparkline and the source range used to generate it. Individual sparklines are typically obtained from an ISparklineGroup.


 worksheet.getRange("A1:C1").setValue(new Object[] {10, 20, 15});
 ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
 ISparkline sparkline = group.get(0);
 IRange location = sparkline.getLocation();
 String sourceData = sparkline.getSourceData();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Generates the sparkline from the JSON string.
    Gets the location of a single sparkline.
    Gets the range that contains the source data for a single sparkline.
    void
    Sets the location of a single sparkline.
    void
    Sets the range that contains the source data for a single sparkline.
    Generates a JSON string from the sparkline.
  • Method Details

    • getLocation

      IRange getLocation()
      Gets the location of a single sparkline.

      Returns the IRange that represents the cell where the sparkline is displayed.

      
       worksheet.getRange("A1:B2").setValue(new Object[][] {
           {10, 20},
           {30, 40}
       });
       ISparkline sparkline = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:B1").get(0);
       IRange location = sparkline.getLocation();
       
      Returns:
      The IRange object that represents the location of a single sparkline.
    • setLocation

      void setLocation(IRange value)
      Sets the location of a single sparkline.

      Use this method to move the sparkline to another cell by specifying the IRange that represents its display location.

      
       worksheet.getRange("A1:C1").setValue(new Object[] {1, 3, 2});
       ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
       ISparkline sparkline = group.get(0);
       sparkline.setLocation(worksheet.getRange("E1"));
       
      Parameters:
      value - The IRange object that represents the location of the sparkline.
    • getSourceData

      String getSourceData()
      Gets the range that contains the source data for a single sparkline.

      Use this method to retrieve the range reference string currently used by the sparkline. To change the source range, use setSourceData(String).

      
       worksheet.getRange("A1:C1").setValue(new Object[] {1, 3, 2});
       ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
       ISparkline sparkline = group.get(0);
       String sourceData = sparkline.getSourceData();
       
      Returns:
      The range reference string that contains the source data for the sparkline.
    • setSourceData

      void setSourceData(String value)
      Sets the range that contains the source data for a single sparkline.
      
       worksheet.getRange("A1:D1").setValue(new Object[] {1, 3, 2, 4});
       ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
       ISparkline sparkline = group.get(0);
       sparkline.setSourceData("A1:D1");
       
      Parameters:
      value - The range reference string that contains the source data for the sparkline.
    • fromJson

      void fromJson(String json)
      Generates the sparkline from the JSON string.

      Use this method to restore a sparkline from a JSON string created by toJson().

      
       worksheet.getRange("A1:C1").setValue(new Object[] {1, 3, 2});
       ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
       ISparkline sparkline = group.get(0);
       String json = sparkline.toJson();
       sparkline.fromJson(json);
       
      Parameters:
      json - The JSON string representing the sparkline.
    • toJson

      String toJson()
      Generates a JSON string from the sparkline.

      Use this method to serialize the current sparkline so it can be passed to fromJson(String) to restore the sparkline configuration.

      
       worksheet.getRange("A1:C1").setValue(new Object[] {1, 3, 2});
       ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
       ISparkline sparkline = group.get(0);
       String json = sparkline.toJson();
       
      Returns:
      The JSON string representing the sparkline.