[]
        
(Showing Draft Content)

IColorStop

Interface IColorStop


public interface IColorStop
Represents a gradient stop in a gradient fill for a range or selection.

Use this interface to read or change the color, theme color, tint/shade, and position of a single gradient stop in a linear or rectangular gradient. The position is a value from 0.0 to 1.0, where 0.0 represents the start of the gradient and 1.0 represents the end.


 IRange range = worksheet.getRange("A1");
 range.getInterior().setPattern(Pattern.LinearGradient);

 ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
 IColorStops colorStops = gradient.getColorStops();

 colorStops.get(0).setColor(Color.GetRed());
 colorStops.get(0).setPosition(0.0);

 colorStops.get(1).setColor(Color.GetBlue());
 colorStops.get(1).setPosition(1.0);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes this gradient stop from the gradient fill.
    Gets the color of this gradient stop.
    double
    Gets the position of this gradient stop.
    Gets the theme color of this gradient stop.
    double
    Gets the tint and shade adjustment of this gradient stop.
    void
    setColor(Color value)
    Sets the color of this gradient stop.
    void
    setPosition(double value)
    Sets the position of this gradient stop.
    void
    Sets the theme color of this gradient stop.
    void
    setTintAndShade(double value)
    Sets the tint and shade adjustment of this gradient stop.
  • Method Details

    • getColor

      Color getColor()
      Gets the color of this gradient stop.

      Use this method to read the direct color assigned to a gradient stop.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
       IColorStop colorStop = ((ILinearGradient) range.getInterior().getGradient()).getColorStops().get(0);
       colorStop.setColor(Color.GetRed());
       Color color = colorStop.getColor();
       
      Returns:
      The Color object assigned directly to this gradient stop.
    • setColor

      void setColor(Color value)
      Sets the color of this gradient stop.

      Use this method to change the direct color assigned to a gradient stop.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
       IColorStop colorStop = ((ILinearGradient) range.getInterior().getGradient()).getColorStops().get(0);
       colorStop.setColor(Color.GetRed());
       
      Parameters:
      value - The direct color to assign to this gradient stop.
    • getPosition

      double getPosition()
      Gets the position of this gradient stop.

      The position specifies where the gradient stop is placed in the gradient transition. The valid range is 0.0 to 1.0, where 0.0 represents the start of the gradient and 1.0 represents the end.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
      
       ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
       IColorStop colorStop = gradient.getColorStops().get(1);
      
       colorStop.setPosition(1.0);
       double position = colorStop.getPosition();
       
      Returns:
      The position of this gradient stop, from 0.0 to 1.0.
    • setPosition

      void setPosition(double value)
      Sets the position of this gradient stop.

      The position specifies where the gradient stop is placed in the gradient transition. The valid range is 0.0 to 1.0, where 0.0 represents the start of the gradient and 1.0 represents the end.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
      
       ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
       IColorStop colorStop = gradient.getColorStops().get(1);
      
       colorStop.setPosition(1.0);
       
      Parameters:
      value - The position of this gradient stop, from 0.0 to 1.0.
    • getThemeColor

      ThemeColor getThemeColor()
      Gets the theme color of this gradient stop.

      Use this method to read the theme color assigned to a gradient stop. If the gradient stop does not use a theme color, this method returns ThemeColor.None.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
       IColorStop colorStop = ((ILinearGradient) range.getInterior().getGradient()).getColorStops().get(0);
       colorStop.setThemeColor(ThemeColor.Accent1);
       ThemeColor themeColor = colorStop.getThemeColor();
       
      Returns:
      The ThemeColor value assigned to this gradient stop, or ThemeColor.None if this gradient stop does not use a theme color.
    • setThemeColor

      void setThemeColor(ThemeColor value)
      Sets the theme color of this gradient stop.

      Use this method to apply a workbook theme color to a gradient stop.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
       IColorStop colorStop = ((ILinearGradient) range.getInterior().getGradient()).getColorStops().get(0);
       colorStop.setThemeColor(ThemeColor.Accent1);
       
      Parameters:
      value - The workbook theme color to apply to this gradient stop.
    • getTintAndShade

      double getTintAndShade()
      Gets the tint and shade adjustment of this gradient stop.

      Use a value from -1.0 to 1.0, where 0 means no adjustment, negative values make the color darker, and positive values make the color lighter.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
      
       IColorStop colorStop = ((ILinearGradient) range.getInterior().getGradient()).getColorStops().get(0);
      
       colorStop.setThemeColor(ThemeColor.Accent1);
       colorStop.setTintAndShade(0.25);
      
       double tintAndShade = colorStop.getTintAndShade();
       
      Returns:
      The tint and shade adjustment value of this gradient stop, from -1.0 to 1.0.
    • setTintAndShade

      void setTintAndShade(double value)
      Sets the tint and shade adjustment of this gradient stop.

      Use a value from -1.0 to 1.0, where 0 means no adjustment, negative values make the color darker, and positive values make the color lighter.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
      
       IColorStop colorStop = ((ILinearGradient) range.getInterior().getGradient()).getColorStops().get(0);
      
       colorStop.setThemeColor(ThemeColor.Accent1);
       colorStop.setTintAndShade(0.25);
       
      Parameters:
      value - The tint and shade adjustment value of this gradient stop, from -1.0 to 1.0.
    • delete

      void delete()
      Deletes this gradient stop from the gradient fill.

      After deleting a gradient stop, get the IColorStops collection from the gradient again before accessing the remaining gradient stops.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
      
       ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
       IColorStops colorStops = gradient.getColorStops();
      
       IColorStop colorStop = colorStops.get(1);
       colorStop.delete();
      
       IColorStops updatedColorStops =
               ((ILinearGradient) range.getInterior().getGradient()).getColorStops();
       int count = updatedColorStops.getCount();