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

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


    }

    @Test
    public void testRange() throws Exception {
        String rangeStr = "'Лист1'!$A$1:$C$1";
        Range range = Range.fromFormula(rangeStr);
        Assert.assertEquals(rangeStr, range.toString());
    }
View Full Code Here


        if (definedNames != null) {
            List<CTDefinedName> definedName = definedNames.getDefinedName();
            for (CTDefinedName name1 : definedName) {
                for (CTDefinedName name2 : definedName) {
                    if (!name1.equals(name2)) {
                        Range range1 = Range.fromFormula(name1.getValue());
                        Range range2 = Range.fromFormula(name2.getValue());
                        if (range1.intersectsByVertical(range2)) {
                            rangeVerticalIntersections.put(range1, range2);
                            rangeVerticalIntersections.put(range2, range1);
                        }
                    }
View Full Code Here

        for (Map.Entry<Range, Document.ChartWrapper> entry : result.getChartSpaces().entrySet()) {
            for (Range templateRange : rangeDependencies.keySet()) {
                if (templateRange.contains(entry.getKey())) {
                    List<Range> chartBandResultRanges = rangeDependencies.get(templateRange);
                    if (chartBandResultRanges.size() > 0) {
                        Range firstResultRange = getFirst(chartBandResultRanges);

                        shiftChart(entry.getValue(), templateRange, firstResultRange);

                        CTChart chart = entry.getValue().getChartSpace().getChart();
                        CTPlotArea plotArea = chart.getPlotArea();
                        List<Object> areaChartOrArea3DChartOrLineChart = plotArea.getAreaChartOrArea3DChartOrLineChart();
                        for (Object o : areaChartOrArea3DChartOrLineChart) {
                            if (o instanceof ListSer) {
                                ListSer series = (ListSer) o;
                                List<SerContent> ser = series.getSer();
                                for (SerContent ctBarSer : ser) {
                                    CTAxDataSource captions = ctBarSer.getCat();
                                    if (captions != null && captions.getStrRef() != null) {
                                        Range temlpateCaptionsRange = Range.fromFormula(captions.getStrRef().getF());
                                        for (Range bandRange : rangeDependencies.keySet()) {
                                            if (bandRange.contains(temlpateCaptionsRange)) {
                                                List<Range> seriesResultRanges = rangeDependencies.get(bandRange);

                                                Range seriesFirstRange = getFirst(seriesResultRanges);
                                                Range seriesLastRange = getLast(seriesResultRanges);

                                                Offset offset = calculateOffset(temlpateCaptionsRange, seriesFirstRange);
                                                Offset initialOffset = calculateOffset(temlpateCaptionsRange, bandRange);
                                                temlpateCaptionsRange = temlpateCaptionsRange.shift(
                                                        offset.downOffset - initialOffset.downOffset,
                                                        offset.rightOffset - initialOffset.rightOffset);

                                                Offset grow = calculateOffset(seriesFirstRange, seriesLastRange);
                                                temlpateCaptionsRange.grow(grow.downOffset, grow.rightOffset);

                                                captions.getStrRef().setF(temlpateCaptionsRange.toFormula());
                                                break;
                                            }
                                        }
                                    }

                                    CTNumDataSource data = ctBarSer.getVal();
                                    if (data != null && data.getNumRef() != null) {
                                        Range templateDataRange = Range.fromFormula(data.getNumRef().getF());
                                        for (Range bandRange : rangeDependencies.keySet()) {
                                            if (bandRange.contains(templateDataRange)) {
                                                List<Range> seriesResultRanges = rangeDependencies.get(bandRange);

                                                Range seriesFirstRange = getFirst(seriesResultRanges);
                                                Range seriesLastRange = getLast(seriesResultRanges);

                                                Offset offset = calculateOffset(templateDataRange, seriesFirstRange);
                                                Offset initialOffset = calculateOffset(templateDataRange, bandRange);
                                                templateDataRange = templateDataRange.shift(
                                                        offset.downOffset - initialOffset.downOffset,
View Full Code Here

        CTCalcChain calculationChain = getCalculationChain();

        for (Cell cellWithFormula : innerFormulas) {
            Row row = (Row) cellWithFormula.getParent();
            Worksheet worksheet = getWorksheet(row);
            Range formulaRange = Range.fromCellFormula(result.getSheetName(worksheet), cellWithFormula);
            Range originalFormulaRange = formulaRange.copy();
            for (Range templateRange : rangeDependencies.keySet()) {
                if (templateRange.contains(formulaRange)) {
                    List<Range> resultRanges = rangeDependencies.get(templateRange);

                    CellReference cellReference = new CellReference(result.getSheetName(worksheet), cellWithFormula.getR());
                    for (Range resultRange : resultRanges) {
                        if (resultRange.contains(cellReference)) {
                            Offset offset = calculateOffset(templateRange, resultRange);

                            formulaRange = formulaRange.shift(offset.downOffset, offset.rightOffset);
                            updateFormula(cellWithFormula, originalFormulaRange, formulaRange, calculationChain, formulaCount++);
                            break;
                        }
                    }
                }
            }
        }

        for (Cell cellWithFormula : outerFormulas) {
            Row row = (Row) cellWithFormula.getParent();
            Worksheet worksheet = getWorksheet(row);
            Range formulaRange = Range.fromCellFormula(result.getSheetName(worksheet), cellWithFormula);
            Range originalFormulaRange = formulaRange.copy();
            CellReference formulaCellReference = new CellReference(result.getSheetName(worksheet), cellWithFormula.getR());

            BandData parentBand = null;
            for (Range resultRange : rangeDependencies.values()) {
                if (resultRange.contains(formulaCellReference)) {
                    BandData formulaCellBand = bandsToResultRanges.inverse().get(resultRange);
                    parentBand = formulaCellBand.getParentBand();
                }
            }

            for (Range templateRange : rangeDependencies.keySet()) {
                if (templateRange.contains(formulaRange)) {
                    List<Range> resultRanges = new ArrayList<Range>(rangeDependencies.get(templateRange));
                    for (Iterator<Range> iterator = resultRanges.iterator(); iterator.hasNext(); ) {
                        Range resultRange = iterator.next();
                        BandData bandData = bandsToResultRanges.inverse().get(resultRange);
                        if (!bandData.getParentBand().equals(parentBand)) {
                            iterator.remove();
                        }
                    }

                    if (resultRanges.size() > 0) {
                        Range firstResultRange = getFirst(resultRanges);
                        Range lastResultRange = getLast(resultRanges);

                        Offset offset = calculateOffset(templateRange, firstResultRange);
                        formulaRange = formulaRange.shift(offset.downOffset, offset.rightOffset);

                        Offset grow = calculateOffset(firstResultRange, lastResultRange);
View Full Code Here

            }

            for (Range resultRange : rangeDependencies.get(templateRange)) {
                if (templateSheet.getMergeCells() != null && templateSheet.getMergeCells().getMergeCell() != null) {
                    for (CTMergeCell templateMergeRegion : templateSheet.getMergeCells().getMergeCell()) {
                        Range mergeRange = Range.fromRange(templateRange.getSheet(), templateMergeRegion.getRef());
                        if (templateRange.contains(mergeRange)) {
                            Offset offset = calculateOffset(templateRange, resultRange);
                            Range resultMergeRange = mergeRange.copy().shift(offset.downOffset, offset.rightOffset);
                            CTMergeCell resultMergeRegion = new CTMergeCell();
                            resultMergeRegion.setRef(resultMergeRange.toRange());
                            resultMergeRegion.setParent(resultSheet.getMergeCells());
                            resultSheet.getMergeCells().getMergeCell().add(resultMergeRegion);
                        }
                    }
                }
View Full Code Here

            throw wrapWithReportingException(String.format("An error occurred while rendering band [%s]", childBand.getName()), e);
        }
    }

    protected void writeHBand(BandData band) {
        Range templateRange = getBandRange(band);
        Worksheet resultSheet = result.getSheetByName(templateRange.getSheet());
        List<Row> resultSheetRows = resultSheet.getSheetData().getRow();

        Row firstRow = findNextRowForHBand(band, templateRange, resultSheetRows);
        firstRow = ensureNecessaryRowsCreated(templateRange, resultSheet, firstRow);
View Full Code Here

            }
        }
    }

    protected void writeVBand(BandData band) {
        Range templateRange = getBandRange(band);
        Worksheet resultSheet = result.getSheetByName(templateRange.getSheet());
        List<Row> resultSheetRows = resultSheet.getSheetData().getRow();

        Row firstRow = findNextRowForVBand(band, templateRange, resultSheetRows);
        firstRow = ensureNecessaryRowsCreated(templateRange, resultSheet, firstRow);
View Full Code Here

        updateRangeMappings(band, templateRange, resultCells);
    }

    protected void updateRangeMappings(BandData band, Range templateRange, List<Cell> resultCells) {
        if (CollectionUtils.isNotEmpty(resultCells)) {
            Range resultRange = Range.fromCells(templateRange.getSheet(), getFirst(resultCells).getR(), resultCells.get(resultCells.size() - 1).getR());
            rangeDependencies.put(templateRange, resultRange);
            bandsToTemplateRanges.forcePut(band, templateRange);
            bandsToResultRanges.forcePut(band, resultRange);
        }
    }
View Full Code Here

        boolean isFirstLevelBand = BandData.ROOT_BAND_NAME.equals(band.getParentBand().getName());

        List<Range> alreadyRenderedRanges = findAlreadyRenderedRanges(band);

        if (CollectionUtils.isNotEmpty(alreadyRenderedRanges)) {//this band has been already rendered at least once
            Range lastRenderedRange = alreadyRenderedRanges.get(alreadyRenderedRanges.size() - 1);
            BandData lastRenderedBand = bandsToResultRanges.inverse().get(lastRenderedRange);
            LastRowBandVisitor bandVisitor = new LastRowBandVisitor();
            lastRenderedBand.visit(bandVisitor);

            if (resultSheetRows.size() > bandVisitor.lastRow) {//get next row
View Full Code Here

        List<Range> alreadyRenderedRanges = findAlreadyRenderedRanges(band);

        previousRangesRightOffset = 0;
        if (CollectionUtils.isNotEmpty(alreadyRenderedRanges)) {//this band has been already rendered at least once
            Range previousRange = getLast(alreadyRenderedRanges);
            previousRangesRightOffset = previousRange.getFirstColumn() - templateRange.getFirstColumn() + 1;
            if (resultSheetRows.size() > previousRange.getFirstRow() - 1) {//get current row
                firstRow = resultSheetRows.get(previousRange.getFirstRow() - 1);
            }
        } else if (!isFirstLevelBand) {
            firstRow = findNextRowForChildBand(band, templateRange, resultSheetRows);
        } else {//this is the first render
            firstRow = findNextRowForFirstRender(templateRange, resultSheetRows);
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.