[]
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();
}
IColorStops for the ILinearGradient object.doublevoidsetDegree(double value) 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();
}
IColorStops collection for this ILinearGradient object.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();
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);
value - The angle of the linear gradient fill.