# Manage Shape Options

Learn the various ways offered by DsExcel to format the shape and text in the worksheet.

## Content

In DsExcel, you can customize the shape format in three different ways. This includes setting the fill format for the inserted shape using the properties and methods of the [IFillFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html) interface, configuring the shape's line using the properties and methods of the [ILineFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/ILineFormat.html) interface and applying 3D formatting to the shape using the properties and methods of the [IThreeDFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IThreeDFormat.html) interface.

## Solid Fill

To format the shape with Solid fill, first you need to use the [Solid](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#solid) method of the **IFillFormat** interface to specify the fill format and then set the [setRGB](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IColorFormat.html#setRGB) and [setTransparency](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#setTransparency) to set the shape's fill color and transparency degree respectively.
Refer to the following example code to fill the shape with solid fill.

```Java
// Solid fill
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Parallelogram, 1, 1, 200, 100);
shape.getFill().solid();
shape.getFill().getColor().setRGB(Color.GetRed());
```

## Gradient Fill

With gradient fill, you can configure the shape fill to the gradient fill using the [oneColorGradient](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#oneColorGradient) method, [twoColorGradient](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#twoColorGradient) method or [presetGradient](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#presetGradient) method of the [IFillFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html) interface.
After setting the gradient fill, you can insert, delete or change gradient stops; configure the fill style rotation along with the shape and the angle of the gradient fill via the [getGradientStops](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#getGradientStops) method, [setRotateWithObject](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#setRotateWithObject) method and [setGradientAngle](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#setGradientAngle) method of the [IFillFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html) interface.
Four types of gradient fills, namely line, radial, rectangular and path are supported by DsExcel. By default, the 'Line' gradient fill is applied.
Refer to the following example code to fill the shape with gradient fill using presetGradient method.

```Java
// Gradient fill
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Heart, 1, 1, 100, 100);
shape.getFill().presetGradient(GradientStyle.Vertical, 3, PresetGradientType.Silver);
shape.getFill().setRotateWithObject(false);
```

Refer to the following example code to fill the shape with gradient fill using twoColorGradient method.

```Java
// Initialize workbook
Workbook workbook = new Workbook();
// Fetch default worksheet
IWorksheet worksheet = workbook.getWorksheets().get(0);

// Add a shape
IShape rectangle = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 300, 100);

// Init a two color gradient fill.          
rectangle.getFill().twoColorGradient(GradientStyle.Horizontal, 1);   

//save to an excel file
workbook.save("LineGradient.xlsx");
```

To set the radial, rectangular or path gradient fill, you also need to set the **PathShapeType** along with using the **twoColorGradient** method.
Refer to the following example code to fill the shape with 'Radial' gradient fill.

```Java
// Initialize workbook
Workbook workbook = new Workbook();
// Fetch default worksheet
IWorksheet worksheet = workbook.getWorksheets().get(0);

// Add a shape
IShape rectangle = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 300, 100);

// Init a two color gradient fill.          
rectangle.getFill().twoColorGradient(GradientStyle.FromCenter, 1);
       
rectangle.getFill().getGradientPathType().equals(PathShapeType.Radial);

//save to an excel file
workbook.save("RadialGradient.xlsx");
```

## Pattern Fill

With pattern fill, you can set the shape fill to pattern fill using the [patterned](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#patterned) method of the [IFillFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html) interface.
Further, you can also configure the background color and the pattern color using [setObjectThemeColor](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IColorFormat.html#setObjectThemeColor) method of the [IColorFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IColorFormat.html) interface and [getPatternColor](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#getPatternColor) method of the [IFillFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html) interface.
In order to fill the shape with pattern fill, refer to the following example code.

```Java
// Pattern fill
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 1, 1, 100, 100);
shape.getFill().patterned(PatternType.Percent10);
shape.getFill().getColor().setObjectThemeColor(ThemeColor.Accent2);
shape.getFill().getPatternColor().setObjectThemeColor(ThemeColor.Accent6);
```

## Picture Fill

In picture fill, you can use the [addShape](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IShapes.html#addShape) method of the [IShapes](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IShapes.html) interface to insert the shape that you want to fill with a picture.
Also, you can configure the picture format with characteristics like picture height, picture width, brightness, contrast ratio, re-coloring, x-axis and y-axis offset etc using the methods of the [IPictureFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IPictureFormat.html) interface.
In order to fill the shape with picture, refer to the following example code.

```Java
// Add shape of picture type
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 100);
String path = "C:\\Users\\GPCTAdmin\\Pictures\\cat.jpg";

try {
FileInputStream stream = new FileInputStream(path);
shape.getFill().userPicture(stream, ImageType.JPG);
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
// Recolor the picture
shape.getPictureFormat().setColorType(PictureColorType.Grayscale);

// Set picture brightness and contrast ratio
shape.getPictureFormat().setBrightness(0.6);
shape.getPictureFormat().setContrast(0.3);

// Set height, width, x-axis offset and y-axis offset of the specified picture
shape.getPictureFormat().getCrop().setPictureOffsetX(10);
shape.getPictureFormat().getCrop().setPictureOffsetY(-5);
shape.getPictureFormat().getCrop().setPictureWidth(120);
shape.getPictureFormat().getCrop().setPictureHeight(80);
```

## Texture Fill

Using texture fill, you can fill the shape with texture of your choice using the [presetTextured](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#presetTextured) method of the [IFillFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html) interface.
Further, you can also configure the layout of the texture using the [setTextureAlignment](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#getTextureAlignment) method, [setTextureHorizontalScale](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#getTextureHorizontalScale) method, [setTextureOffsetX](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#getTextureOffsetX) method, [setTextureOffsetY](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#getTextureOffsetY) method and [setTextureVerticalScale](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IFillFormat.html#getTextureVerticalScale) method.
In order to fill the shape with texture fill, refer to the following example code.

```Java
// Texture Fill
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 1, 1, 100, 100);
shape.getFill().presetTextured(PresetTexture.Canvas);
shape.getFill().setTextureAlignment(TextureAlignment.Center);
shape.getFill().setTextureOffsetX(2.5);
shape.getFill().setTextureOffsetY(3.2);
shape.getFill().setTextureHorizontalScale(0.9);
shape.getFill().setTextureVerticalScale(0.2);
shape.getFill().setTransparency(0.5);
```

## Line

Line is a kind of border around the shape. You can create lines around shapes inserted on cells of a spreadsheet using the properties and methods of [ILineFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/ILineFormat.html) interface.
Refer to the following example code to configure the line and line style for the shape.

```Java
// To set shape's line style.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 1, 1, 100, 100);
shape.getLine().setDashStyle(LineDashStyle.Dash);
shape.getLine().setStyle(LineStyle.Single);
shape.getLine().setWeight(2);
shape.getLine().getColor().setObjectThemeColor(ThemeColor.Accent6);
shape.getLine().setTransparency(0.3);
```

>type=note
> **Note**: Shape's Line also supports solid fill, gradient fill and pattern fill and its usage is similar to the Shape Fill.

## 3D Formatting

DsExcel Java enables users to format the three-dimensional layout for the inserted shape via configuring its rotation degree around x, y and z axis. This can be done using the [setRotationX](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IThreeDFormat.html#setRotationX) method, the [setRotationY](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IThreeDFormat.html#setRotationY) method and the [setRotationZ](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/drawing/IThreeDFormat.html#setRotationZ) method of the IThreeDFormat interface.
In order to apply 3D formatting to the embedded shape, refer to the following example code.

```Java
// To set rotation degree for the shape arround x, y, z axis.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 1, 1, 100, 100);
shape.getThreeD().setRotationX(50);
shape.getThreeD().setRotationY(20);
shape.getThreeD().setRotationZ(30);
shape.getThreeD().setDepth(7);
shape.getThreeD().setZ(20);
```