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

项目: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;
}
项目:dataforms    文件:ExcelReport.java   
/**
 * セルに対し画像を設定します。
 * @param c セル。
 * @param value 値。
 * @param p セル位置情報。
 */
private void setImage(final Cell c, final Object value, final CellPosition p) {
    ImageData img = (ImageData) value;
    int cidx = c.getColumnIndex();
    int ridx = c.getRowIndex();
    ClientAnchor anchor = new XSSFClientAnchor();
    anchor.setCol1(cidx);
    anchor.setCol2(cidx + p.getColumns());
    anchor.setRow1(ridx);
    anchor.setRow2(ridx + p.getRows());
    anchor.setDx1(XSSFShape.EMU_PER_PIXEL * p.getDx1());
    anchor.setDy1(XSSFShape.EMU_PER_PIXEL * p.getDy1());
    anchor.setDx2(XSSFShape.EMU_PER_PIXEL * p.getDx2());
    anchor.setDy2(XSSFShape.EMU_PER_PIXEL * p.getDy2());
    anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE);
    int imgtype = XSSFWorkbook.PICTURE_TYPE_PNG;
    if (ImageData.CONTENT_TYPE_JPEG.equals(img.getContentType())) {
        imgtype = XSSFWorkbook.PICTURE_TYPE_JPEG;
    } else if (ImageData.CONTENT_TYPE_GIF.equals(img.getContentType())) {
        imgtype = XSSFWorkbook.PICTURE_TYPE_GIF;
    }
    int pidx = this.workbook.addPicture(img.getContents(), imgtype);
    Picture pic = this.drawing.createPicture(anchor, pidx);
    this.resizeImage(c, pic, p);
}
项目:excel2canvas    文件:ExcelToCanvasBuilder.java   
private int[] anchorToPoints(CTTwoCellAnchor anchor) {
    int sCol = anchor.getFrom().getCol();
    int eCol = anchor.getTo().getCol();
    int sRow = anchor.getFrom().getRow();
    int eRow = anchor.getTo().getRow();
    if (this.readRange != null) {
        if (!(sCol >= this.readRange.x && eCol <= this.readRange.width) ||
            !(sRow >= this.readRange.y && eRow <= this.readRange.height)) {
            return null;
        }
    }
    updateWriteCell(eRow, eCol);

    int[] p = new int[4];
    p[0] = (int) (getColLeft(sCol) + (anchor.getFrom().getColOff() / XSSFShape.EMU_PER_PIXEL));
    p[1] = (int) (getRowTop(sRow) + (anchor.getFrom().getRowOff() / XSSFShape.EMU_PER_PIXEL));
    p[2] = (int) (getColLeft(eCol) + (anchor.getTo().getColOff() / XSSFShape.EMU_PER_PIXEL) - p[0]);
    p[3] = (int) (getRowTop(eRow) + (anchor.getTo().getRowOff() / XSSFShape.EMU_PER_PIXEL) - p[1]);
    return p;
}
项目:OCRaptor    文件:XSSFExcelExtractorDecorator.java   
private void processShapes(List<XSSFShape> shapes, XHTMLContentHandler xhtml)
    throws SAXException {
  if (shapes == null) {
    return;
  }
  for (XSSFShape shape : shapes) {
    if (shape instanceof XSSFSimpleShape) {
      String sText = ((XSSFSimpleShape) shape).getText();
      if (sText != null && sText.length() > 0) {
        xhtml.element("p", sText);
      }
    }
  }
}
项目:birt    文件:StyleManagerXUtils.java   
@Override
public int anchorDyFromPoints( float height, float rowHeight ) {
    return (int)( height * XSSFShape.EMU_PER_POINT );
}