Example usage for org.apache.poi.xssf.usermodel XSSFPicture getCTPicture

List of usage examples for org.apache.poi.xssf.usermodel XSSFPicture getCTPicture

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFPicture getCTPicture.

Prototype

@Internal
public CTPicture getCTPicture() 

Source Link

Document

Return the underlying CTPicture bean that holds all properties for this picture

Usage

From source file:com.vodafone.poms.ii.helpers.ExportManager.java

private static int addImageToShape(XSSFSheet sh, XSSFClientAnchor imgAnchor, int imgId) {
    XSSFDrawing pat = sh.createDrawingPatriarch();
    XSSFPicture pic = pat.createPicture(imgAnchor, imgId);

    CTPicture cPic = pic.getCTPicture();
    int shapeId = (int) cPic.getNvPicPr().getCNvPr().getId();
    cPic.getNvPicPr().getCNvPr().setHidden(true);
    CTOfficeArtExtensionList extLst = cPic.getNvPicPr().getCNvPicPr().addNewExtLst();
    // https://msdn.microsoft.com/en-us/library/dd911027(v=office.12).aspx
    CTOfficeArtExtension ext = extLst.addNewExt();
    ext.setUri("{63B3BB69-23CF-44E3-9099-C40C66FF867C}");
    XmlCursor cur = ext.newCursor();/*  ww  w . j  a va  2  s .c  o  m*/
    cur.toEndToken();
    cur.beginElement(new QName(drawNS, "compatExt", "a14"));
    cur.insertAttributeWithValue("spid", "_x0000_s" + shapeId);

    return shapeId;
}