Example usage for org.apache.poi.hssf.usermodel HSSFPicture getPictureIndex

List of usage examples for org.apache.poi.hssf.usermodel HSSFPicture getPictureIndex

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFPicture getPictureIndex.

Prototype

public int getPictureIndex() 

Source Link

Usage

From source file:cn.afterturn.easypoi.util.PoiPublicUtil.java

License:Apache License

/**
 * ?Excel2003/* w w w. j a  v  a  2s  .  co m*/
 *
 * @param sheet
 *            ?sheet
 * @param workbook
 *            
 * @return Map key:?1_1Stringvalue:?PictureData
 */
public static Map<String, PictureData> getSheetPictrues03(HSSFSheet sheet, HSSFWorkbook workbook) {
    Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
    List<HSSFPictureData> pictures = workbook.getAllPictures();
    if (!pictures.isEmpty()) {
        for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
            HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor();
            if (shape instanceof HSSFPicture) {
                HSSFPicture pic = (HSSFPicture) shape;
                int pictureIndex = pic.getPictureIndex() - 1;
                HSSFPictureData picData = pictures.get(pictureIndex);
                String picIndex = String.valueOf(anchor.getRow1()) + "_" + String.valueOf(anchor.getCol1());
                sheetIndexPicMap.put(picIndex, picData);
            }
        }
        return sheetIndexPicMap;
    } else {
        return sheetIndexPicMap;
    }
}

From source file:com.qihang.winter.poi.util.PoiPublicUtil.java

License:Apache License

/**
 * ?Excel2003/*from  ww w  .  j  a  v a 2s  .  c  o  m*/
 * 
 * @param sheet
 *            ?sheet
 * @param workbook
 *            
 * @return Map key:?1_1Stringvalue:?PictureData
 */
public static Map<String, PictureData> getSheetPictrues03(HSSFSheet sheet, HSSFWorkbook workbook) {
    Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
    List<HSSFPictureData> pictures = workbook.getAllPictures();
    if (!pictures.isEmpty()) {
        for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) {
            HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor();
            if (shape instanceof HSSFPicture) {
                HSSFPicture pic = (HSSFPicture) shape;
                int pictureIndex = pic.getPictureIndex() - 1;
                HSSFPictureData picData = pictures.get(pictureIndex);
                String picIndex = String.valueOf(anchor.getRow1()) + "_" + String.valueOf(anchor.getCol1());
                sheetIndexPicMap.put(picIndex, picData);
            }
        }
        return sheetIndexPicMap;
    } else {
        return null;
    }
}