/** * Creates a chart. * * @param anchor * the client anchor describes how this chart is attached to the * sheet. * @return the newly created chart * @see org.apache.poi.xssf.usermodel.XSSFDrawing#createChart(ClientAnchor) */ public XSSFChart createChart(XSSFClientAnchor anchor) { int chartNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.CHART.getContentType()) .size() + 1; RelationPart rp = createRelationship(XSSFRelation.CHART, XSSFFactory.getInstance(), chartNumber, false); XSSFChart chart = rp.getDocumentPart(); String chartRelId = rp.getRelationship().getId(); XSSFGraphicFrame frame = createGraphicFrame(anchor); frame.setChart(chart, chartRelId); frame.getCTGraphicalObjectFrame().setXfrm(createXfrm(anchor)); return chart; }
/** * Creates a new graphic frame. * * @param anchor * the client anchor describes how this frame is attached to the * sheet * @return the newly created graphic frame */ private XSSFGraphicFrame createGraphicFrame(XSSFClientAnchor anchor) { CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTGraphicalObjectFrame ctGraphicFrame = ctAnchor.addNewGraphicFrame(); ctGraphicFrame.set(XSSFGraphicFrame.prototype()); ctGraphicFrame.setXfrm(createXfrm(anchor)); long frameId = numOfGraphicFrames++; XSSFGraphicFrame graphicFrame = new XSSFGraphicFrame(this, ctGraphicFrame); graphicFrame.setAnchor(anchor); graphicFrame.setId(frameId); graphicFrame.setName("Diagramm" + frameId); return graphicFrame; }
/** * Creates a simple shape. This includes such shapes as lines, rectangles, * and ovals. * * @param anchor * the client anchor describes how this group is attached to the * sheet. * @return the newly created shape. */ public XSSFSimpleShape createSimpleShape(XSSFClientAnchor anchor) { long shapeId = newShapeId(); CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTShape ctShape = ctAnchor.addNewSp(); ctShape.set(XSSFSimpleShape.prototype()); ctShape.getNvSpPr().getCNvPr().setId(shapeId); ctShape.getSpPr().setXfrm(createXfrm(anchor)); XSSFSimpleShape shape = new XSSFSimpleShape(this, ctShape); shape.anchor = anchor; return shape; }
/** * Creates a simple shape. This includes such shapes as lines, rectangles, * and ovals. * * @param anchor * the client anchor describes how this group is attached to the * sheet. * @return the newly created shape. */ public XSSFShapeGroup createGroup(XSSFClientAnchor anchor) { CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTGroupShape ctGroup = ctAnchor.addNewGrpSp(); ctGroup.set(XSSFShapeGroup.prototype()); CTTransform2D xfrm = createXfrm(anchor); CTGroupTransform2D grpXfrm = ctGroup.getGrpSpPr().getXfrm(); grpXfrm.setOff(xfrm.getOff()); grpXfrm.setExt(xfrm.getExt()); grpXfrm.setChExt(xfrm.getExt()); XSSFShapeGroup shape = new XSSFShapeGroup(this, ctGroup); shape.anchor = anchor; return shape; }
/** * Creates a picture. * * @param anchor * the client anchor describes how this picture is attached to * the sheet. * @param pictureIndex * the index of the picture in the workbook collection of * pictures, * {@link org.apache.poi.xssf.usermodel.XSSFWorkbook#getAllPictures()} * . * * @return the newly created picture shape. */ public XSSFPicture createPicture(XSSFClientAnchor anchor, int pictureIndex) { PackageRelationship rel = addPictureReference(pictureIndex); long shapeId = newShapeId(); CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTPicture ctShape = ctAnchor.addNewPic(); ctShape.set(XSSFPicture.prototype()); ctShape.getNvPicPr().getCNvPr().setId(shapeId); XSSFPicture shape = new XSSFPicture(this, ctShape); shape.anchor = anchor; shape.setPictureReference(rel); ctShape.getSpPr().setXfrm(createXfrm(anchor)); return shape; }
ctShape.getSpPr().setXfrm(createXfrm((XSSFClientAnchor) anchor));
/** * Creates a chart. * * @param anchor * the client anchor describes how this chart is attached to the * sheet. * @return the newly created chart * @see org.apache.poi.xssf.usermodel.XSSFDrawing#createChart(ClientAnchor) */ public XSSFChart createChart(XSSFClientAnchor anchor) { int chartNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.CHART.getContentType()) .size() + 1; RelationPart rp = createRelationship(XSSFRelation.CHART, XSSFFactory.getInstance(), chartNumber, false); XSSFChart chart = rp.getDocumentPart(); String chartRelId = rp.getRelationship().getId(); XSSFGraphicFrame frame = createGraphicFrame(anchor); frame.setChart(chart, chartRelId); frame.getCTGraphicalObjectFrame().setXfrm(createXfrm(anchor)); return chart; }
/** * Creates a new graphic frame. * * @param anchor * the client anchor describes how this frame is attached to the * sheet * @return the newly created graphic frame */ private XSSFGraphicFrame createGraphicFrame(XSSFClientAnchor anchor) { CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTGraphicalObjectFrame ctGraphicFrame = ctAnchor.addNewGraphicFrame(); ctGraphicFrame.set(XSSFGraphicFrame.prototype()); ctGraphicFrame.setXfrm(createXfrm(anchor)); long frameId = numOfGraphicFrames++; XSSFGraphicFrame graphicFrame = new XSSFGraphicFrame(this, ctGraphicFrame); graphicFrame.setAnchor(anchor); graphicFrame.setId(frameId); graphicFrame.setName("Diagramm" + frameId); return graphicFrame; }
/** * Creates a simple shape. This includes such shapes as lines, rectangles, * and ovals. * * @param anchor * the client anchor describes how this group is attached to the * sheet. * @return the newly created shape. */ public XSSFSimpleShape createSimpleShape(XSSFClientAnchor anchor) { long shapeId = newShapeId(); CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTShape ctShape = ctAnchor.addNewSp(); ctShape.set(XSSFSimpleShape.prototype()); ctShape.getNvSpPr().getCNvPr().setId(shapeId); ctShape.getSpPr().setXfrm(createXfrm(anchor)); XSSFSimpleShape shape = new XSSFSimpleShape(this, ctShape); shape.anchor = anchor; return shape; }
/** * Creates a simple shape. This includes such shapes as lines, rectangles, * and ovals. * * @param anchor * the client anchor describes how this group is attached to the * sheet. * @return the newly created shape. */ public XSSFShapeGroup createGroup(XSSFClientAnchor anchor) { CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTGroupShape ctGroup = ctAnchor.addNewGrpSp(); ctGroup.set(XSSFShapeGroup.prototype()); CTTransform2D xfrm = createXfrm(anchor); CTGroupTransform2D grpXfrm = ctGroup.getGrpSpPr().getXfrm(); grpXfrm.setOff(xfrm.getOff()); grpXfrm.setExt(xfrm.getExt()); grpXfrm.setChExt(xfrm.getExt()); XSSFShapeGroup shape = new XSSFShapeGroup(this, ctGroup); shape.anchor = anchor; return shape; }
/** * Creates a picture. * * @param anchor * the client anchor describes how this picture is attached to * the sheet. * @param pictureIndex * the index of the picture in the workbook collection of * pictures, * {@link org.apache.poi.xssf.usermodel.XSSFWorkbook#getAllPictures()} * . * * @return the newly created picture shape. */ public XSSFPicture createPicture(XSSFClientAnchor anchor, int pictureIndex) { PackageRelationship rel = addPictureReference(pictureIndex); long shapeId = newShapeId(); CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTPicture ctShape = ctAnchor.addNewPic(); ctShape.set(XSSFPicture.prototype()); ctShape.getNvPicPr().getCNvPr().setId(shapeId); XSSFPicture shape = new XSSFPicture(this, ctShape); shape.anchor = anchor; shape.setPictureReference(rel); ctShape.getSpPr().setXfrm(createXfrm(anchor)); return shape; }
ctShape.getSpPr().setXfrm(createXfrm((XSSFClientAnchor) anchor));