Package com.haulmont.yarg.formatters.impl.xlsx

Examples of com.haulmont.yarg.formatters.impl.xlsx.Range


        return firstRow;
    }

    protected Row findNextRowForChildBand(BandData band, Range templateRange, List<Row> resultSheetRows) {
        BandData parentBand = band.getParentBand();
        Range resultParentRange = bandsToResultRanges.get(parentBand);
        Range templateParentRange = bandsToTemplateRanges.get(parentBand);

        if (resultParentRange != null && templateParentRange != null) {
            if (templateParentRange.getFirstRow() == templateRange.getFirstRow()) {
                if (resultSheetRows.size() > resultParentRange.getFirstRow() - 1) {//get current row
                    return resultSheetRows.get(resultParentRange.getFirstRow() - 1);
                }
            } else {
                LastRowBandVisitor bandVisitor = new LastRowBandVisitor();
View Full Code Here


    protected Row findNextRowForFirstRender(Range templateRange, List<Row> resultSheetRows) {
        Collection<Range> templateNeighbours = rangeVerticalIntersections.get(templateRange);
        for (Range templateNeighbour : templateNeighbours) {
            Collection<Range> resultRanges = rangeDependencies.get(templateNeighbour);
            if (resultRanges.size() > 0) {
                Range firstResultRange = resultRanges.iterator().next();
                return resultSheetRows.get(firstResultRange.getFirstRow() - 1);//get current  row
            }
        }
        return null;
    }
View Full Code Here

    }

    protected List<Cell> copyCells(BandData band, Range templateRange, List<Row> resultSheetRows, Row firstRow) {
        List<Cell> resultCells = new ArrayList<Cell>();
        for (int i = 0; i <= templateRange.getLastRow() - templateRange.getFirstRow(); i++) {
            Range oneRowRange = new Range(templateRange.getSheet(), templateRange.getFirstColumn(), templateRange.getFirstRow() + i, templateRange.getLastColumn(), templateRange.getFirstRow() + i);
            List<Cell> templateCells = template.getCellsByRange(oneRowRange);

            if (CollectionUtils.isNotEmpty(templateCells)) {
                Row templateRow = (Row) templateCells.get(0).getParent();
                Row resultRow = resultSheetRows.get((int) (firstRow.getR() + i - 1));
View Full Code Here

    protected List<Range> findAlreadyRenderedRanges(BandData band) {
        List<Range> alreadyRenderedRanges = new ArrayList<Range>();
        List<BandData> sameLevelBands = band.getParentBand().getChildrenByName(band.getName());
        for (BandData sameLevelBand : sameLevelBands) {
            Range range = bandsToResultRanges.get(sameLevelBand);
            if (range != null) {
                alreadyRenderedRanges.add(range);
            }
        }
View Full Code Here

        return newCell;
    }

    protected void addFormulaForPostProcessing(Range templateRange, Row newRow, Cell templateCell, Cell newCell) {
        Worksheet worksheet = getWorksheet(newRow);
        Range formulaRange = Range.fromCellFormula(result.getSheetName(worksheet), templateCell);
        if (templateRange.contains(formulaRange)) {
            innerFormulas.add(newCell);
        } else {
            outerFormulas.add(newCell);
        }
View Full Code Here

    protected class LastRowBandVisitor implements BandVisitor {
        private int lastRow = 0;

        @Override
        public boolean visit(BandData band) {
            Range range = bandsToResultRanges.get(band);
            if (range != null && range.getLastRow() > lastRow) {
                lastRow = range.getLastRow();
            }
            return false;
        }
View Full Code Here

            bottomRight = new CellReference(rownum + rowsAddedByHorizontalBand - 1, offset + currentColumnCount);
            resultRange = new AreaReference(topLeft, bottomRight);

            areaDependencyManager.addDependency(new Area(band.getName(), Area.AreaAlign.HORIZONTAL, templateRange),
                    new Area(band.getName(), Area.AreaAlign.HORIZONTAL, resultRange));
            bandsToResultRanges.put(band, new Range(resultSheet.getSheetName(),
                    resultRange.getFirstCell().getCol() + 1, resultRange.getFirstCell().getRow() + 1,
                    resultRange.getLastCell().getCol() + 1, resultRange.getLastCell().getRow() + 1
            ));
        }
View Full Code Here

        if (crefs != null) {
            addRangeBounds(band, crefs);

            Bounds thisBounds = templateBounds.get(band.getName());
            Bounds parentBounds = templateBounds.get(band.getParentBand().getName());
            Range parentRange = bandsToResultRanges.get(band.getParentBand());

            int localRowNum = parentBounds != null && parentRange != null ?
                    parentRange.getFirstRow() - 1 + thisBounds.row0 - parentBounds.row0 :
                    rownum;

            colnum = colnum == 0 ? getCellFromReference(crefs[0], templateSheet).getColumnIndex() : colnum;
            copyMergeRegions(resultSheet, rangeName, localRowNum, colnum);

            int firstRow = crefs[0].getRow();
            int firstColumn = crefs[0].getCol();

            for (CellReference cref : crefs) {//create necessary rows
                int currentRow = cref.getRow();
                final int rowOffset = currentRow - firstRow;
                if (!rowExists(resultSheet, localRowNum + rowOffset)) {
                    HSSFRow resultRow = resultSheet.createRow(localRowNum + rowOffset);
                    copyPageBreaks(templateSheet, resultSheet, cref.getRow(), resultRow.getRowNum());
                }
                addedRowNumbers.add(cref.getRow());
            }

            CellReference topLeft = null;
            CellReference bottomRight = null;
            for (CellReference cref : crefs) {
                int currentRow = cref.getRow();
                int currentColumn = cref.getCol();
                final int rowOffset = currentRow - firstRow;
                final int columnOffset = currentColumn - firstColumn;

                HSSFCell templateCell = getCellFromReference(cref, templateSheet);
                resultSheet.setColumnWidth(colnum + columnOffset, templateSheet.getColumnWidth(templateCell.getColumnIndex()));
                HSSFCell resultCell = copyCellFromTemplate(templateCell, resultSheet.getRow(localRowNum + rowOffset), colnum + columnOffset, band);
                if (topLeft == null) {
                    topLeft = new CellReference(resultCell);
                }
                bottomRight = new CellReference(resultCell);
            }

            colnum += crefs[crefs.length - 1].getCol() - firstColumn + 1;

            AreaReference templateRange = getAreaForRange(templateWorkbook, rangeName);
            AreaReference resultRange = new AreaReference(topLeft, bottomRight);
            areaDependencyManager.addDependency(new Area(band.getName(), Area.AreaAlign.VERTICAL, templateRange),
                    new Area(band.getName(), Area.AreaAlign.VERTICAL, resultRange));
            bandsToResultRanges.put(band, new Range(resultSheet.getSheetName(),
                    resultRange.getFirstCell().getCol() + 1, resultRange.getFirstCell().getRow() + 1,
                    resultRange.getLastCell().getCol() + 1, resultRange.getLastCell().getRow() + 1
            ));
        }
View Full Code Here

TOP

Related Classes of com.haulmont.yarg.formatters.impl.xlsx.Range

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.