[]
        
(Showing Draft Content)

ILinearGradient

Interface ILinearGradient


public interface ILinearGradient
Represents the ILinearGradient object that transitions through a series of colors in a linear manner along a specific angle.

Use this interface to configure a linear gradient fill by defining its color stops and the angle of the gradient direction.


 IRange range = worksheet.getRange("A1");
 range.getInterior().setPattern(Pattern.LinearGradient);
 ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
 gradient.setDegree(45);
 gradient.getColorStops().add(0).setColor(Color.GetRed());
 gradient.getColorStops().add(1).setColor(Color.GetBlue());
 boolean hasRed = false;
 boolean hasBlue = false;
 for (int i = 0; i < gradient.getColorStops().getCount(); i++) {
     int colorArgb = gradient.getColorStops().get(i).getColor().toArgb();
     hasRed = hasRed || colorArgb == Color.GetRed().toArgb();
     hasBlue = hasBlue || colorArgb == Color.GetBlue().toArgb();
 }
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the IColorStops for the ILinearGradient object.
    double
    Gets the angle of the linear gradient fill within a selection.
    void
    setDegree(double value)
    Sets the angle of the linear gradient fill within a selection.
  • Method Details

    • getColorStops

      IColorStops getColorStops()
      Gets the IColorStops for the ILinearGradient object.

      Use the returned collection to access or add the color stops that define the linear gradient transition.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
       ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
       IColorStops colorStops = gradient.getColorStops();
       colorStops.add(0).setColor(Color.GetRed());
       boolean hasRed = false;
       for (int i = 0; i < colorStops.getCount(); i++) {
           hasRed = hasRed || colorStops.get(i).getColor().toArgb() == Color.GetRed().toArgb();
       }
       
      Returns:
      The IColorStops collection for this ILinearGradient object.
    • getDegree

      double getDegree()
      Gets the angle of the linear gradient fill within a selection.

      Use this property to determine the current direction of the ILinearGradient transition.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
       ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
       gradient.setDegree(45);
       double degree = gradient.getDegree();
       
      Returns:
      The angle of the linear gradient fill.
    • setDegree

      void setDegree(double value)
      Sets the angle of the linear gradient fill within a selection.

      Use this property to set the direction of the ILinearGradient transition.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
       ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
       gradient.setDegree(45);
       
      Parameters:
      value - The angle of the linear gradient fill.