Example usage for org.apache.poi.ss.usermodel Drawing createPicture

List of usage examples for org.apache.poi.ss.usermodel Drawing createPicture

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Drawing createPicture.

Prototype

Picture createPicture(ClientAnchor anchor, int pictureIndex);

Source Link

Document

Creates a picture.

Usage

From source file:functions.excels.Excel.java

License:Apache License

/**
 * Colle le logo en haut  gauche de la page donne.
 * @param page//from ww  w. j av  a  2  s .  c  o  m
 * @throws IOException
 */
public void collerLogo(int page) throws IOException {
    InputStream is = new FileInputStream("public/images/banniere-aer.png");
    byte[] bytes = IOUtils.toByteArray(is);
    int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
    is.close();
    CreationHelper helper = wb.getCreationHelper();
    Sheet sheet = wb.getSheetAt(0);
    // 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(0);
    anchor.setRow1(LIGNES * page);
    Picture pict = drawing.createPicture(anchor, pictureIdx);
    //auto-size picture relative to its top-left corner
    pict.resize();
}

From source file:functions.excels.Excel.java

License:Apache License

/**
 * Insre la carte en paramtre  la page donne
 * @param carte/* w w  w .  j  a v  a  2 s.c  o  m*/
 * @param page
 * @throws IOException
 */
public void pasteMap(Carte carte, int page) throws IOException {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    ImageIO.write(carte.getImage(), "png", os);
    byte[] bytes = os.toByteArray();
    int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
    CreationHelper helper = wb.getCreationHelper();
    Sheet sheet = wb.getSheetAt(0);
    // 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(4);
    anchor.setRow1(LIGNES * page + 10);
    Picture pict = drawing.createPicture(anchor, pictureIdx);
    //auto-size picture relative to its top-left corner
    pict.resize();
}

From source file:info.informationsea.tableio.excel.ExcelImageSheetWriter.java

License:Open Source License

public void addImage(ImageType type, byte[] data) {
    int pictureType;
    switch (type) {
    case TYPE_JPEG:
        pictureType = Workbook.PICTURE_TYPE_JPEG;
        break;/*from   w  w w. j a  va2s  .  com*/
    case TYPE_PNG:
        pictureType = Workbook.PICTURE_TYPE_PNG;
        break;
    default:
        throw new IllegalArgumentException("Image type should be jpeg or png");
    }

    int pictureIndex = sheet.getWorkbook().addPicture(data, pictureType);

    CreationHelper creationHelper = sheet.getWorkbook().getCreationHelper();
    Drawing drawing = sheet.createDrawingPatriarch();
    ClientAnchor anchor = creationHelper.createClientAnchor();
    anchor.setCol1(1);
    anchor.setRow1(nextRow);
    Picture picture = drawing.createPicture(anchor, pictureIndex);
    picture.resize();
    nextRow = picture.getPreferredSize().getRow2() + 1;
}

From source file:it.eng.spagobi.engines.worksheet.exporter.WorkSheetXLSExporter.java

License:Mozilla Public License

public void setImageIntoWorkSheet(Workbook wb, Drawing drawing, File f, int col, int colend, int sheetRow,
        int height, int imgType) throws IOException {
    FileInputStream fis = new FileInputStream(f);

    ByteArrayOutputStream imgBytes = new ByteArrayOutputStream();
    int b;//www . j a va2s .c om
    while ((b = fis.read()) != -1) {
        imgBytes.write(b);
    }
    int dx1 = 0;
    int dy1 = 0;
    int dx2 = 0;
    int dy2 = 0;

    int index = wb.addPicture(imgBytes.toByteArray(), imgType);
    imgBytes.close();
    fis.close();

    ClientAnchor anchor = getClientAnchor(col, colend, sheetRow, height, dx1, dy1, dx2, dy2);
    drawing.createPicture(anchor, index);

}

From source file:nc.noumea.mairie.appock.services.impl.ExportExcelServiceImpl.java

License:Open Source License

private void insertPhotoArticleCatalogueInCell(Workbook wb, Sheet sheet, ArticleCatalogue articleCatalogue,
        int ligne, Row row, boolean mouvementStock) throws IOException {
    File fichierPhotoArticleCatalogue = catalogueService
            .getFilePieceJointe(articleCatalogue.getPhotoArticleCatalogue());
    byte[] bytes = Files.readAllBytes(fichierPhotoArticleCatalogue.toPath());
    int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
    Drawing drawing = sheet.createDrawingPatriarch();
    CreationHelper helper = wb.getCreationHelper();
    ClientAnchor anchor = helper.createClientAnchor();
    anchor.setCol1(10);//from   w  w w  .  j  a va2s .c om
    anchor.setRow1(ligne);
    anchor.setCol2(11);
    anchor.setRow2(ligne + 1);
    drawing.createPicture(anchor, pictureIdx);
    construitLigneExportCatalogueGeneric(wb, row, null, 10, mouvementStock);
}

From source file:net.rrm.ehour.ui.timesheet.export.excel.part.ExportReportHeader.java

License:Open Source License

private int addLogo(int rowNumber) {
    ImageLogo excelLogo = getConfigurationService().getExcelLogo();

    if (excelLogo == null) {
        return rowNumber;
    }/*  w  ww . j ava 2  s.c o m*/

    byte[] image = excelLogo.getImageData();

    int index = getWorkbook().addPicture(image, PoiUtil.getImageType(excelLogo.getImageType()));

    ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) 1, 0, (short) 8, 7);

    Drawing patriarch = getSheet().createDrawingPatriarch();
    patriarch.createPicture(anchor, index);
    anchor.setAnchorType(0); // 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.

    return rowNumber;
}

From source file:org.bbreak.excella.reports.tag.ImageParamParser.java

License:Open Source License

/**
 * ??//from w ww .  jav  a  2 s  . co m
 * 
 * @param sheet ?
 * @param cell 
 * @param filePath ?
 * @param dx1 ??
 * @param dy1 ???
 * @param scale ???
 * @throws ParseException
 */
public void replaceImageValue(Sheet sheet, Cell cell, String filePath, Integer dx1, Integer dy1, Double scale)
        throws ParseException {

    Workbook workbook = sheet.getWorkbook();

    int format = -1;
    if (filePath.toLowerCase().endsWith(JPEG_SUFFIX) || filePath.toLowerCase().endsWith(JPG_SUFFIX)) {
        format = Workbook.PICTURE_TYPE_JPEG;
    } else if (filePath.toLowerCase().endsWith(PNG_SUFFIX)) {
        format = Workbook.PICTURE_TYPE_PNG;
    }
    if (format == -1) {
        throw new ParseException(cell,
                "????????" + filePath);
    }

    byte[] bytes = null;
    InputStream is = null;
    try {
        is = new FileInputStream(filePath);
        bytes = IOUtils.toByteArray(is);
    } catch (Exception e) {
        throw new ParseException(cell, e);
    } finally {
        try {
            is.close();
        } catch (IOException e) {
            throw new ParseException(cell, e);
        }
    }

    int pictureIdx = workbook.addPicture(bytes, format);

    CreationHelper helper = workbook.getCreationHelper();

    @SuppressWarnings("rawtypes")
    Drawing drawing = drawingCash.get(sheet);
    if (drawing == null) {
        drawing = sheet.createDrawingPatriarch();
        drawingCash.put(sheet, drawing);
    }

    ClientAnchor anchor = helper.createClientAnchor();

    anchor.setRow1(cell.getRowIndex());
    anchor.setCol1(cell.getColumnIndex());
    anchor.setRow2(cell.getRowIndex() + 1);
    anchor.setCol2(cell.getColumnIndex() + 1);
    if (dx1 != null) {
        anchor.setDx1(dx1);
    }
    if (dy1 != null) {
        anchor.setDy1(dy1);
    }

    Picture picture = drawing.createPicture(anchor, pictureIdx);
    picture.resize(scale);

}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.xls.helper.ExcelImageHandler.java

License:Open Source License

/**
 * Produces the content for image or drawable cells. Excel does not support image-content in cells. Images are
 * rendered to an embedded OLE canvas instead, which is then positioned over the cell that would contain the image.
 *
 * @param layoutContext// w w  w .  ja  v  a  2 s  .  c  o  m
 *          the stylesheet of the render node that produced the image.
 * @param image
 *          the image object
 * @param currentLayout
 *          the current sheet layout containing all row and column breaks
 * @param rectangle
 *          the current cell in grid-coordinates
 * @param cellBounds
 *          the bounds of the cell.
 */
public void createImageCell(final StyleSheet layoutContext, final ImageContainer image,
        final SlimSheetLayout currentLayout, TableRectangle rectangle, final StrictBounds cellBounds) {
    try {
        if (rectangle == null) {
            // there was an error while computing the grid-position for this
            // element. Evil me...
            logger.debug("Invalid reference: I was not able to compute the rectangle for the content."); // NON-NLS
            return;
        }

        final boolean shouldScale = layoutContext.getBooleanStyleProperty(ElementStyleKeys.SCALE);

        final int imageWidth = image.getImageWidth();
        final int imageHeight = image.getImageHeight();
        if (imageWidth < 1 || imageHeight < 1) {
            return;
        }

        final double scaleFactor = computeImageScaleFactor();

        final ElementAlignment horizontalAlignment = (ElementAlignment) layoutContext
                .getStyleProperty(ElementStyleKeys.ALIGNMENT);
        final ElementAlignment verticalAlignment = (ElementAlignment) layoutContext
                .getStyleProperty(ElementStyleKeys.VALIGNMENT);

        final long internalImageWidth = StrictGeomUtility.toInternalValue(scaleFactor * imageWidth);
        final long internalImageHeight = StrictGeomUtility.toInternalValue(scaleFactor * imageHeight);

        final long cellWidth = cellBounds.getWidth();
        final long cellHeight = cellBounds.getHeight();

        final StrictBounds cb;
        final int pictureId;
        try {
            if (shouldScale) {
                final double scaleX;
                final double scaleY;

                final boolean keepAspectRatio = layoutContext
                        .getBooleanStyleProperty(ElementStyleKeys.KEEP_ASPECT_RATIO);
                if (keepAspectRatio) {
                    final double imgScaleFactor = Math.min(cellWidth / (double) internalImageWidth,
                            cellHeight / (double) internalImageHeight);
                    scaleX = imgScaleFactor;
                    scaleY = imgScaleFactor;
                } else {
                    scaleX = cellWidth / (double) internalImageWidth;
                    scaleY = cellHeight / (double) internalImageHeight;
                }

                final long clipWidth = (long) (scaleX * internalImageWidth);
                final long clipHeight = (long) (scaleY * internalImageHeight);

                final long alignmentX = RenderUtility.computeHorizontalAlignment(horizontalAlignment, cellWidth,
                        clipWidth);
                final long alignmentY = RenderUtility.computeVerticalAlignment(verticalAlignment, cellHeight,
                        clipHeight);

                cb = new StrictBounds(cellBounds.getX() + alignmentX, cellBounds.getY() + alignmentY,
                        Math.min(clipWidth, cellWidth), Math.min(clipHeight, cellHeight));

                // Recompute the cells that this image will cover (now that it has been resized)
                rectangle = currentLayout.getTableBounds(cb, rectangle);

                pictureId = loadImage(image);
                if (printerBase.isUseXlsxFormat()) {
                    if (pictureId < 0) {
                        return;
                    }
                } else if (pictureId <= 0) {
                    return;
                }
            } else {
                // unscaled ..
                if (internalImageWidth <= cellWidth && internalImageHeight <= cellHeight) {
                    // No clipping needed.
                    final long alignmentX = RenderUtility.computeHorizontalAlignment(horizontalAlignment,
                            cellBounds.getWidth(), internalImageWidth);
                    final long alignmentY = RenderUtility.computeVerticalAlignment(verticalAlignment,
                            cellBounds.getHeight(), internalImageHeight);

                    cb = new StrictBounds(cellBounds.getX() + alignmentX, cellBounds.getY() + alignmentY,
                            internalImageWidth, internalImageHeight);

                    // Recompute the cells that this image will cover (now that it has been resized)
                    rectangle = currentLayout.getTableBounds(cb, rectangle);

                    pictureId = loadImage(image);
                    if (printerBase.isUseXlsxFormat()) {
                        if (pictureId < 0) {
                            return;
                        }
                    } else if (pictureId <= 0) {
                        return;
                    }
                } else {
                    // at least somewhere there is clipping needed.
                    final long clipWidth = Math.min(cellWidth, internalImageWidth);
                    final long clipHeight = Math.min(cellHeight, internalImageHeight);
                    final long alignmentX = RenderUtility.computeHorizontalAlignment(horizontalAlignment,
                            cellBounds.getWidth(), clipWidth);
                    final long alignmentY = RenderUtility.computeVerticalAlignment(verticalAlignment,
                            cellBounds.getHeight(), clipHeight);
                    cb = new StrictBounds(cellBounds.getX() + alignmentX, cellBounds.getY() + alignmentY,
                            clipWidth, clipHeight);

                    // Recompute the cells that this image will cover (now that it has been resized)
                    rectangle = currentLayout.getTableBounds(cb, rectangle);

                    pictureId = loadImageWithClipping(image, clipWidth, clipHeight, scaleFactor);
                    if (printerBase.isUseXlsxFormat()) {
                        if (pictureId < 0) {
                            return;
                        }
                    } else if (pictureId <= 0) {
                        return;
                    }
                }
            }
        } catch (final UnsupportedEncoderException uee) {
            // should not happen, as PNG is always supported.
            logger.warn("Assertation-Failure: PNG encoding failed.", uee); // NON-NLS
            return;
        }

        final ClientAnchor anchor = computeClientAnchor(currentLayout, rectangle, cb);

        Drawing patriarch = printerBase.getDrawingPatriarch();

        final Picture picture = patriarch.createPicture(anchor, pictureId);
        logger.info(String.format("Created image: %d => %s", pictureId, picture)); // NON-NLS
    } catch (final IOException e) {
        logger.warn("Failed to add image. Ignoring.", e); // NON-NLS
    }
}

From source file:org.seasar.fisshplate.core.element.Picture.java

License:Apache License

/**
 * ??//from www.ja v  a2  s . co m
 *
 * @param picturepath
 * @param rowRangeIntVal
 * @param cellRangeIntVal
 * @param context
 * @throws FPMergeException
 */
private void writePicture(String picturepath, int cellRangeIntVal, int rowRangeIntVal, FPContext context)
        throws FPMergeException {

    FileInputStream imgFis = FileInputStreamUtil.createFileInputStream(picturepath);
    BufferedImage img = ImageIOUtil.read(imgFis);
    FileInputStreamUtil.close(imgFis);

    Workbook workbook = cell.getRow().getSheet().getWorkbook().getHSSFWorkbook();
    Drawing patriarch = context.getPartriarch();

    int imgWidth = img.getWidth();
    int imgHeight = img.getHeight();
    int cellNo = context.getCurrentCellNum();
    int rowNo = context.getCurrentRowNum();
    ClientAnchor anchor = createAnchor(imgWidth, imgHeight, cellNo, rowNo, cellRangeIntVal, rowRangeIntVal);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    String suffix = StringUtil.parseSuffix(picturepath);
    ImageIOUtil.write(img, suffix, baos);

    byte[] pictureData = baos.toByteArray();
    int pictureType = setupPictureType(suffix);
    int pictureIndex = workbook.addPicture(pictureData, pictureType);

    patriarch.createPicture(anchor, pictureIndex);

    ImageIOUtil.close(baos);
}

From source file:org.waterforpeople.mapping.dataexport.GraphicalSurveySummaryExporter.java

License:Open Source License

/**
 * Writes the report as an XLS document/* ww  w.ja  v a2 s .  c o  m*/
 */
private void writeSummaryReport(Map<QuestionGroupDto, List<QuestionDto>> questionMap, SummaryModel summaryModel,
        String sector, Workbook wb) throws Exception {
    String title = sector == null ? SUMMARY_LABEL.get(locale) : sector;
    Sheet sheet = null;
    int sheetCount = 2;
    String curTitle = WorkbookUtil.createSafeSheetName(title);
    while (sheet == null) {
        sheet = wb.getSheet(curTitle);
        if (sheet == null) {
            sheet = wb.createSheet(WorkbookUtil.createSafeSheetName(curTitle));
        } else {
            sheet = null;
            curTitle = title + " " + sheetCount;
            sheetCount++;
        }
    }
    CreationHelper creationHelper = wb.getCreationHelper();
    Drawing patriarch = sheet.createDrawingPatriarch();
    int curRow = 0;
    Row row = getRow(curRow++, sheet);
    if (sector == null) {
        createCell(row, 0, REPORT_HEADER.get(locale), headerStyle);
    } else {
        createCell(row, 0, sector + " " + REPORT_HEADER.get(locale), headerStyle);
    }
    for (QuestionGroupDto group : orderedGroupList) {
        if (questionMap.get(group) != null) {
            for (QuestionDto question : questionMap.get(group)) {
                if (!(QuestionType.OPTION == question.getType() || QuestionType.NUMBER == question.getType())) {
                    continue;
                } else {
                    if (summaryModel.getResponseCountsForQuestion(question.getKeyId(), sector).size() == 0) {
                        // if there is no data, skip the question
                        continue;
                    }
                }
                // for both options and numeric, we want a pie chart and
                // data table for numeric, we also want descriptive
                // statistics
                int tableTopRow = curRow++;
                int tableBottomRow = curRow;
                row = getRow(tableTopRow, sheet);
                // span the question heading over the data table
                sheet.addMergedRegion(new CellRangeAddress(curRow - 1, curRow - 1, 0, 2));
                createCell(row, 0, getLocalizedText(question.getText(), question.getTranslationMap()),
                        headerStyle);
                DescriptiveStats stats = summaryModel.getDescriptiveStatsForQuestion(question.getKeyId(),
                        sector);
                if (stats != null && stats.getSampleCount() > 0) {
                    sheet.addMergedRegion(new CellRangeAddress(curRow - 1, curRow - 1, 4, 5));
                    createCell(row, 4, getLocalizedText(question.getText(), question.getTranslationMap()),
                            headerStyle);
                }
                row = getRow(curRow++, sheet);
                createCell(row, 1, FREQ_LABEL.get(locale), headerStyle);
                createCell(row, 2, PCT_LABEL.get(locale), headerStyle);

                // now create the data table for the option count
                Map<String, Long> counts = summaryModel.getResponseCountsForQuestion(question.getKeyId(),
                        sector);
                int sampleTotal = 0;
                List<String> labels = new ArrayList<String>();
                List<String> values = new ArrayList<String>();
                int firstOptRow = curRow;
                for (Entry<String, Long> count : counts.entrySet()) {
                    row = getRow(curRow++, sheet);
                    String labelText = count.getKey();
                    if (labelText == null) {
                        labelText = "";
                    }
                    StringBuilder builder = new StringBuilder();
                    if (QuestionType.OPTION == question.getType() && !DEFAULT_LOCALE.equals(locale)) {
                        String[] tokens = labelText.split("\\|");
                        // see if we have a translation for this option
                        for (int i = 0; i < tokens.length; i++) {
                            if (i > 0) {
                                builder.append("|");
                            }
                            if (question.getOptionContainerDto() != null
                                    && question.getOptionContainerDto().getOptionsList() != null) {
                                boolean found = false;
                                for (QuestionOptionDto opt : question.getOptionContainerDto()
                                        .getOptionsList()) {
                                    if (opt.getText() != null
                                            && opt.getText().trim().equalsIgnoreCase(tokens[i])) {
                                        builder.append(getLocalizedText(tokens[i], opt.getTranslationMap()));
                                        found = true;
                                        break;
                                    }
                                }
                                if (!found) {
                                    builder.append(tokens[i]);
                                }
                            }
                        }
                    } else {
                        builder.append(labelText);
                    }
                    createCell(row, 0, builder.toString(), null);
                    createCell(row, 1, count.getValue().toString(), null);

                    labels.add(builder.toString());
                    values.add(count.getValue().toString());
                    sampleTotal += count.getValue();
                }
                row = getRow(curRow++, sheet);
                createCell(row, 0, TOTAL_LABEL.get(locale), null);
                createCell(row, 1, sampleTotal + "", null);
                for (int i = 0; i < values.size(); i++) {
                    row = getRow(firstOptRow + i, sheet);
                    if (sampleTotal > 0) {
                        createCell(row, 2, PCT_FMT.format((Double.parseDouble(values.get(i)) / sampleTotal)),
                                null);
                    } else {
                        createCell(row, 2, PCT_FMT.format(0), null);
                    }
                }

                tableBottomRow = curRow;

                if (stats != null && stats.getSampleCount() > 0) {
                    int tempRow = tableTopRow + 1;
                    row = getRow(tempRow++, sheet);
                    createCell(row, 4, "N", null);
                    createCell(row, 5, sampleTotal + "", null);
                    row = getRow(tempRow++, sheet);
                    createCell(row, 4, MEAN_LABEL.get(locale), null);
                    createCell(row, 5, stats.getMean() + "", null);
                    row = getRow(tempRow++, sheet);
                    createCell(row, 4, STD_E_LABEL.get(locale), null);
                    createCell(row, 5, stats.getStandardError() + "", null);
                    row = getRow(tempRow++, sheet);
                    createCell(row, 4, MEDIAN_LABEL.get(locale), null);
                    createCell(row, 5, stats.getMedian() + "", null);
                    row = getRow(tempRow++, sheet);
                    createCell(row, 4, MODE_LABEL.get(locale), null);
                    createCell(row, 5, stats.getMode() + "", null);
                    row = getRow(tempRow++, sheet);
                    createCell(row, 4, STD_D_LABEL.get(locale), null);
                    createCell(row, 5, stats.getStandardDeviation() + "", null);
                    row = getRow(tempRow++, sheet);
                    createCell(row, 4, VAR_LABEL.get(locale), null);
                    createCell(row, 5, stats.getVariance() + "", null);
                    row = getRow(tempRow++, sheet);
                    createCell(row, 4, RANGE_LABEL.get(locale), null);
                    createCell(row, 5, stats.getRange() + "", null);
                    row = getRow(tempRow++, sheet);
                    createCell(row, 4, MIN_LABEL.get(locale), null);
                    createCell(row, 5, stats.getMin() + "", null);
                    row = getRow(tempRow++, sheet);
                    createCell(row, 4, MAX_LABEL.get(locale), null);
                    createCell(row, 5, stats.getMax() + "", null);
                    if (tableBottomRow < tempRow) {
                        tableBottomRow = tempRow;
                    }
                }
                curRow = tableBottomRow;
                if (labels.size() > 0) {
                    boolean hasVals = false;
                    if (values != null) {
                        for (String val : values) {
                            try {
                                if (val != null && new Double(val.trim()) > 0D) {
                                    hasVals = true;
                                    break;
                                }
                            } catch (Exception e) {
                                // no-op
                            }
                        }
                    }
                    // only insert the image if we have at least 1 non-zero
                    // value
                    if (hasVals && generateCharts) {
                        // now insert the graph
                        int indx = wb.addPicture(JFreechartChartUtil.getPieChart(labels, values,
                                getLocalizedText(question.getText(), question.getTranslationMap()), CHART_WIDTH,
                                CHART_HEIGHT), Workbook.PICTURE_TYPE_PNG);
                        ClientAnchor anchor = creationHelper.createClientAnchor();
                        anchor.setDx1(0);
                        anchor.setDy1(0);
                        anchor.setDx2(0);
                        anchor.setDy2(255);
                        anchor.setCol1(6);
                        anchor.setRow1(tableTopRow);
                        anchor.setCol2(6 + CHART_CELL_WIDTH);
                        anchor.setRow2(tableTopRow + CHART_CELL_HEIGHT);
                        anchor.setAnchorType(2);
                        patriarch.createPicture(anchor, indx);
                        if (tableTopRow + CHART_CELL_HEIGHT > tableBottomRow) {
                            curRow = tableTopRow + CHART_CELL_HEIGHT;
                        }
                    }
                }

                // add a blank row between questions
                getRow(curRow++, sheet);
                // flush the sheet so far to disk; we will not go back up
                ((SXSSFSheet) sheet).flushRows(0); // retain 0 last rows and
                // flush all others

            }
        }
    }
}