本文整理汇总了Java中org.apache.poi.xssf.usermodel.XSSFPicture类的典型用法代码示例。如果您正苦于以下问题:Java XSSFPicture类的具体用法?Java XSSFPicture怎么用?Java XSSFPicture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XSSFPicture类属于org.apache.poi.xssf.usermodel包,在下文中一共展示了XSSFPicture类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSheetPictrues07
import org.apache.poi.xssf.usermodel.XSSFPicture; //导入依赖的package包/类
/**
* 获取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;
}
示例2: getSheetPictrues07
import org.apache.poi.xssf.usermodel.XSSFPicture; //导入依赖的package包/类
/**
* 获取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;
}
示例3: readAllCellImages
import org.apache.poi.xssf.usermodel.XSSFPicture; //导入依赖的package包/类
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;
}
示例4: setCellPicture
import org.apache.poi.xssf.usermodel.XSSFPicture; //导入依赖的package包/类
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();
}