List of usage examples for org.apache.poi.hssf.usermodel HSSFClientAnchor getRow2
public int getRow2()
From source file:com.haulmont.yarg.formatters.impl.XLSFormatter.java
License:Apache License
/** * Copies all pictures from template sheet to result sheet, shift picture depending on area dependencies * * @param templateSheet - template sheet * @param resultSheet - result sheet/* w w w . j a v a2s. c o m*/ */ protected void copyPicturesFromTemplateToResult(HSSFSheet templateSheet, HSSFSheet resultSheet) { List<HSSFClientAnchor> list = getAllAnchors(getEscherAggregate(templateSheet)); int i = 0; if (CollectionUtils.isNotEmpty(orderedPicturesId)) {//just a shitty workaround for anchors without pictures for (HSSFClientAnchor anchor : list) { Cell topLeft = getCellFromTemplate(new Cell(anchor.getCol1(), anchor.getRow1())); anchor.setCol1(topLeft.getCol()); anchor.setRow1(topLeft.getRow()); anchor.setCol2(topLeft.getCol() + anchor.getCol2() - anchor.getCol1()); anchor.setRow2(topLeft.getRow() + anchor.getRow2() - anchor.getRow1()); HSSFPatriarch sheetPatriarch = drawingPatriarchsMap.get(resultSheet); if (sheetPatriarch != null) { sheetPatriarch.createPicture(anchor, orderedPicturesId.get(i++)); } } } }
From source file:org.jxstar.report.util.ReportXlsUtil.java
/** * ???1SHEET1SHEET/*w w w . j a va2 s .com*/ * * @param destBook -- * @param srcBook -- ?? */ private static void copySheetImage(HSSFWorkbook destBook, HSSFWorkbook srcBook) { //??? HSSFSheet srcSheet = srcBook.getSheetAt(0); //? HSSFSheet destSheet = destBook.getSheetAt(0); //??? int endRowNum = destSheet.getPhysicalNumberOfRows(); //???? List<HSSFPicture> lsSrcPicture = getAllPicture(srcSheet); _log.showDebug("----------source picture size:" + lsSrcPicture.size()); if (lsSrcPicture.isEmpty()) return; //????? List<HSSFPictureData> lsPicData = null; try { lsPicData = srcBook.getAllPictures(); } catch (Exception e) { _log.showWarn( "book?getAllPictures?book??"); HSSFWorkbook tmpBook = copyWorkbook(srcBook); if (tmpBook != null) { lsPicData = tmpBook.getAllPictures(); tmpBook = null; } /* ???? //??? lsPicData = destBook.getAllPictures(); if (lsPicData == null || lsPicData.isEmpty()) return; //??1? List<HSSFPictureData> destData = FactoryUtil.newList(); for (int i = 0, n = lsSrcPicture.size(); i < n; i++) { destData.add(lsPicData.get(0)); } lsPicData = destData;*/ } if (lsPicData == null || lsPicData.isEmpty()) return; _log.showDebug("----------source data size:" + lsPicData.size()); //???? //????sheet???book if (lsSrcPicture.size() > lsPicData.size()) { _log.showWarn("?????"); return; } //?? HSSFPatriarch destDraw = destSheet.getDrawingPatriarch(); if (destDraw == null) { destDraw = destSheet.createDrawingPatriarch(); } //?? List<HSSFPicture> lsDestPicture = getAllPicture(destSheet); int index = lsDestPicture.size(); for (int i = 0, n = lsSrcPicture.size(); i < n; i++) { //? HSSFPicture picture = lsSrcPicture.get(i); //????? HSSFPictureData picdata = lsPicData.get(i); //?? byte[] datas = picdata.getData(); //??? HSSFClientAnchor anchor = (HSSFClientAnchor) picture.getAnchor(); //?? anchor.setRow1(anchor.getRow1() + endRowNum); anchor.setRow2(anchor.getRow2() + endRowNum); //??? destBook.addPicture(datas, picdata.getFormat()); //???????+1?? index++; _log.showDebug("---------copy new image index=" + index); destDraw.createPicture(anchor, index); } }