本文整理匯總了Java中org.apache.poi.xssf.usermodel.XSSFWorkbook.addPicture方法的典型用法代碼示例。如果您正苦於以下問題:Java XSSFWorkbook.addPicture方法的具體用法?Java XSSFWorkbook.addPicture怎麽用?Java XSSFWorkbook.addPicture使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.xssf.usermodel.XSSFWorkbook
的用法示例。
在下文中一共展示了XSSFWorkbook.addPicture方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: extractPicturePortion
import org.apache.poi.xssf.usermodel.XSSFWorkbook; //導入方法依賴的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);
}
}