// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); IShapes shapes = worksheet.getShapes(); IShape rectangle = shapes.addShape(AutoShapeType.Rectangle, 20, 20, 100, 100); rectangle.getFill().getColor().setRGB(Color.FromArgb(169, 209, 142)); IShape oval = shapes.addShape(AutoShapeType.Oval, 50, 50, 100, 100); oval.getFill().getColor().setRGB(Color.FromArgb(157, 195, 230)); IShape triangle = shapes.addShape(AutoShapeType.IsoscelesTriangle, 80, 80, 100, 100); triangle.getFill().getColor().setRGB(Color.FromArgb(255, 230, 153)); // Set rectangle above oval rectangle.zOrder(ZOrderType.BringForward); // Set triangle to bottom triangle.zOrder(ZOrderType.SendToBack); // Save to an excel file workbook.save("SetShapeZOrder.xlsx");