Java 类org.apache.poi.xssf.usermodel.XSSFDrawing 实例源码

项目:poix    文件:PoiPublicUtil.java   
/**
 * 获取Excel2007图片
 * 
 * @param sheet
 *            当前sheet对象
 * @param workbook
 *            工作簿对象
 * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData
 */
public static Map<String, PictureData> getSheetPictrues07(XSSFSheet sheet,
                                                          XSSFWorkbook workbook) {
    Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
    for (POIXMLDocumentPart dr : sheet.getRelations()) {
        if (dr instanceof XSSFDrawing) {
            XSSFDrawing drawing = (XSSFDrawing) dr;
            List<XSSFShape> shapes = drawing.getShapes();
            for (XSSFShape shape : shapes) {
                XSSFPicture pic = (XSSFPicture) shape;
                XSSFClientAnchor anchor = pic.getPreferredSize();
                CTMarker ctMarker = anchor.getFrom();
                String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol();
                sheetIndexPicMap.put(picIndex, pic.getPictureData());
            }
        }
    }
    return sheetIndexPicMap;
}
项目:easypoi    文件:PoiPublicUtil.java   
/**
 * 获取Excel2007图片
 * 
 * @param sheet
 *            当前sheet对象
 * @param workbook
 *            工作簿对象
 * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData
 */
public static Map<String, PictureData> getSheetPictrues07(XSSFSheet sheet, XSSFWorkbook workbook) {
    Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
    for (POIXMLDocumentPart dr : sheet.getRelations()) {
        if (dr instanceof XSSFDrawing) {
            XSSFDrawing drawing = (XSSFDrawing) dr;
            List<XSSFShape> shapes = drawing.getShapes();
            for (XSSFShape shape : shapes) {
                XSSFPicture pic = (XSSFPicture) shape;
                XSSFClientAnchor anchor = pic.getPreferredSize();
                CTMarker ctMarker = anchor.getFrom();
                String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol();
                sheetIndexPicMap.put(picIndex, pic.getPictureData());
            }
        }
    }
    return sheetIndexPicMap;
}
项目:excel2javabeans    文件:ExcelImages.java   
private static Table<Integer, Integer, ImageData> readAllCellImages(XSSFDrawing drawing, Sheet sheet) {
    val images = HashBasedTable.<Integer, Integer, ImageData>create();
    for (val shape : drawing.getShapes()) {
        if (!(shape instanceof XSSFPicture)) continue;

        val picture = (XSSFPicture) shape;
        val imageData = createImageData(picture.getPictureData());

        val axisRow = computeAxisRowIndex(sheet, picture);
        val axisCol = computeAxisColIndex(sheet, picture);

        images.put(axisRow, axisCol, imageData);
    }

    return images;
}
项目:excel2javabeans    文件:ExcelImages.java   
public static Table<Integer, Integer, ImageData> readAllCellImages(Sheet sheet) {
    val patriarch = sheet.getDrawingPatriarch();
    if (patriarch instanceof XSSFDrawing) {
        return readAllCellImages((XSSFDrawing) patriarch, sheet);
    } else if (patriarch instanceof HSSFPatriarch) {
        return readAllCellImages((HSSFPatriarch) patriarch, sheet);
    }

    return HashBasedTable.create();
}
项目:bamboobsc    文件:SimpleUtils.java   
public static void setCellPicture(XSSFWorkbook wb, XSSFSheet sh, byte[] iconBytes, int row, int col) throws Exception {
       int myPictureId = wb.addPicture(iconBytes, XSSFWorkbook.PICTURE_TYPE_PNG);

       XSSFDrawing drawing = sh.createDrawingPatriarch();
       XSSFClientAnchor myAnchor = new XSSFClientAnchor();

       myAnchor.setCol1(col);
       myAnchor.setRow1(row);

       XSSFPicture myPicture = drawing.createPicture(myAnchor, myPictureId);
       myPicture.resize();
}
项目:Gargoyle    文件:ExcelUtil.java   
/**
 * 특정셀에 코멘트를 추가한다.
 *
 * @param sheet
 * @param cell
 * @param commentText
 * @return
 */
public static void addComment(Sheet sheet, Cell cell, String commentText) {
    XSSFDrawing patr = (XSSFDrawing) sheet.createDrawingPatriarch();
    Comment comment = patr.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short) 4, 2, (short) 6, 5));
    comment.setString(new XSSFRichTextString(commentText));
    cell.setCellComment(comment);
}