{
EscherContainerRecord spgrContainer = new EscherContainerRecord();
EscherContainerRecord spContainer = new EscherContainerRecord();
EscherSpgrRecord spgr = new EscherSpgrRecord();
EscherSpRecord sp = new EscherSpRecord();
EscherOptRecord opt = new EscherOptRecord();
EscherRecord anchor;
EscherClientDataRecord clientData = new EscherClientDataRecord();
spgrContainer.setRecordId( EscherContainerRecord.SPGR_CONTAINER );
spgrContainer.setOptions( (short) 0x000F );
spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
spContainer.setOptions( (short) 0x000F );
spgr.setRecordId( EscherSpgrRecord.RECORD_ID );
spgr.setOptions( (short) 0x0001 );
spgr.setRectX1( shape.getX1() );
spgr.setRectY1( shape.getY1() );
spgr.setRectX2( shape.getX2() );
spgr.setRectY2( shape.getY2() );
sp.setRecordId( EscherSpRecord.RECORD_ID );
sp.setOptions( (short) 0x0002 );
int shapeId = drawingManager.allocateShapeId(drawingGroupId);
sp.setShapeId( shapeId );
if (shape.getAnchor() instanceof HSSFClientAnchor)
sp.setFlags( EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_HAVEANCHOR );
else
sp.setFlags( EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_CHILD );
opt.setRecordId( EscherOptRecord.RECORD_ID );
opt.setOptions( (short) 0x0023 );
opt.addEscherProperty( new EscherBoolProperty( EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x00040004 ) );
opt.addEscherProperty( new EscherBoolProperty( EscherProperties.GROUPSHAPE__PRINT, 0x00080000 ) );
anchor = ConvertAnchor.createAnchor( shape.getAnchor() );
// clientAnchor.setCol1( ( (HSSFClientAnchor) shape.getAnchor() ).getCol1() );
// clientAnchor.setRow1( (short) ( (HSSFClientAnchor) shape.getAnchor() ).getRow1() );
// clientAnchor.setDx1( (short) shape.getAnchor().getDx1() );