本文整理汇总了Java中org.apache.poi.xssf.usermodel.XSSFSheet.createDrawingPatriarch方法的典型用法代码示例。如果您正苦于以下问题:Java XSSFSheet.createDrawingPatriarch方法的具体用法?Java XSSFSheet.createDrawingPatriarch怎么用?Java XSSFSheet.createDrawingPatriarch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.xssf.usermodel.XSSFSheet
的用法示例。
在下文中一共展示了XSSFSheet.createDrawingPatriarch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractPicturePortion
import org.apache.poi.xssf.usermodel.XSSFSheet; //导入方法依赖的package包/类
/**
* 抽象出图片生成业务代码
*
* @throws IOException
*/
private void extractPicturePortion(String svgString, XSSFWorkbook wb,
XSSFSheet sheet, int startCol, int endCol, int startRow, int endRow)
throws IOException {
// 图片
if (org.apache.commons.lang3.StringUtils.isNotBlank(svgString)) {
byte[] safeDataBytes = new BASE64Decoder().decodeBuffer(svgString);
int pictureIdx = wb.addPicture(safeDataBytes,
Workbook.PICTURE_TYPE_JPEG);
CreationHelper helper = wb.getCreationHelper();
// Create the drawing patriarch. This is the top level container for
// all shapes.
Drawing drawing = sheet.createDrawingPatriarch();
// add a picture shape
ClientAnchor anchor = helper.createClientAnchor();
// set top-left corner of the picture,
// subsequent call of Picture#resize() will operate relative to it
anchor.setCol1(startCol);
anchor.setCol2(endCol);
anchor.setRow1(startRow);
anchor.setRow2(endRow);
anchor.setDx1(0);
anchor.setDy1(0);
anchor.setDx2(0);
anchor.setDy2(0);
anchor.setAnchorType(ClientAnchor.MOVE_DONT_RESIZE);
Picture pict = drawing.createPicture(anchor, pictureIdx);
pict.resize(1);
}
}
示例2: setCellPicture
import org.apache.poi.xssf.usermodel.XSSFSheet; //导入方法依赖的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();
}