Home Tutorials Poi Creating Shapes using Shape Groups

Related Tutorials


Share on Google+Share on Google+

Creating Shapes using Shape Groups

In this section, you will learn how to create shapes using Apache POI library.

Creating Shapes using Shape Groups

In this section, you will learn how to create shapes using Apache POI library.


import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFChildAnchor;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFShapeGroup;
import org.apache.poi.hssf.usermodel.HSSFSimpleShape;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

public class XLShapeGroup {
public static void main(String args[]) throws FileNotFoundException {
Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet("Data Validation");
HSSFPatriarch patriarch = (HSSFPatriarch) sheet
// Create a shape group.
HSSFShapeGroup group = patriarch.createGroup(new HSSFClientAnchor(0, 0,
900, 200, (short) 0, 1, (short) 1, 0));

// Create a couple of lines in the group.
HSSFSimpleShape shape1 = group.createShape(new HSSFChildAnchor(3, 3,
500, 500));
((HSSFChildAnchor) shape1.getAnchor())
.setAnchor((short) 3, 3, 500, 500);
HSSFSimpleShape shape2 = group.createShape(new HSSFChildAnchor(
(short) 0, 200, 400, 600));
FileOutputStream fileOut = new FileOutputStream("xls/XLShapeGroup.xls");
try {
} catch (IOException e) {


Download Source Code



If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 24, 2011

Related Tutorials

Discuss: Creating Shapes using Shape Groups  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
May 19, 2014
Tickmark in Excel.

Hi, Can anyone help me in understanding how to show a tickmark in a cell for excel while generating using POI.