Skip to content

Commit

Permalink
Avoid overlapping vertical bands #553
Browse files Browse the repository at this point in the history
In case one vertical band comes after another it does not consider actual rendered range of previous band and starts rendering from defined template range.
This fix takes into account already rendered band in the same row and adds appropriate offset for current vertical band
  • Loading branch information
Artem Artemev committed Jun 9, 2022
1 parent d9dd7a1 commit 19e4109
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ private void setPreviousRangeVerticalOffset(int previousRangesRightOffset, BandD
protected Row findNextRowForVBand(BandData band, Range templateRange, List<Row> resultSheetRows) {
Row firstRow = null;
boolean isFirstLevelBand = BandData.ROOT_BAND_NAME.equals(band.getParentBand().getName());
setPreviousRangeVerticalOffset(0, null);
this.previousRangesRightOffset = 0;

Range lastRenderedRange = getLastRenderedBandForThisLevel(band);
if (lastRenderedRange != null) {//this band has been already rendered at least once
Expand All @@ -696,6 +696,18 @@ protected Row findNextRowForVBand(BandData band, Range templateRange, List<Row>
firstRow = findNextRowForChildBand(band, templateRange, resultSheetRows);
} else {//this is the first render
firstRow = findNextRowForFirstRender(templateRange, resultSheetRows);
if (previousRangeBandData != null && firstRow != null) {//row for rendering and previously rendered data already there
Range lastRenderedBandRange = getLastRenderedBandForThisLevel(previousRangeBandData);
if (firstRow.getR() != null && firstRow.getR().intValue() <= lastRenderedBandRange.getLastRow()) {
//we have intersection between previously rendered data and what we want to add
int lastRenderedColumn = lastRenderedBandRange.getLastColumn();
int firstTemplateColumn = templateRange.getFirstColumn();
if (lastRenderedColumn != firstTemplateColumn) {
previousRangesRightOffset = lastRenderedColumn - firstTemplateColumn + 1;
}
previousRangeBandData = band;
}
}
}
return firstRow;
}
Expand Down

0 comments on commit 19e4109

Please sign in to comment.