/** * 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 XSSFWorkbook#getAllPictures()} . * @return the newly Created picture shape. */ public XSSFPicture CreatePicture(XSSFClientAnchor anchor, int pictureIndex) { PackageRelationship rel = GetDrawing().AddPictureReference(pictureIndex); CT_Picture ctShape = ctGroup.AddNewPic(); ctShape.Set(XSSFPicture.Prototype()); XSSFPicture shape = new XSSFPicture(GetDrawing(), ctShape); shape.parent = this; shape.anchor = anchor; shape.SetPictureReference(rel); 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 Npoi.Core.xssf.usermodel.XSSFWorkbook#getAllPictures()} . * * @return the newly Created picture shape. */ public IPicture CreatePicture(XSSFClientAnchor anchor, int pictureIndex) { PackageRelationship rel = AddPictureReference(pictureIndex); long shapeId = newShapeId(); CT_TwoCellAnchor ctAnchor = CreateTwoCellAnchor(anchor); CT_Picture ctShape = ctAnchor.AddNewPic(); ctShape.Set(XSSFPicture.Prototype()); ctShape.nvPicPr.cNvPr.id = (uint)shapeId; ctShape.nvPicPr.cNvPr.name = "Picture " + shapeId; XSSFPicture shape = new XSSFPicture(this, ctShape); shape.anchor = anchor; shape.SetPictureReference(rel); return(shape); }