Skip to content

Commit

Permalink
Merge pull request #149 from cuba-platform/146-fix-copying-defined-names
Browse files Browse the repository at this point in the history
Fixed setup of defined names
  • Loading branch information
Vladislav Selitskii committed Jul 6, 2021
2 parents ed03199 + 48caf01 commit bbad95b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void renderDocument() {
findVerticalDependencies();

result.clearWorkbook();
result.getWorkbook().setDefinedNames(template.getWorkbook().getDefinedNames());
result.clearBandDefinedNames(rootBand);

for (BandData childBand : rootBand.getChildrenList()) {
checkThreadInterrupted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.haulmont.yarg.formatters.impl.xlsx;

import com.haulmont.yarg.exception.ReportFormattingException;
import com.haulmont.yarg.structure.BandData;
import org.docx4j.dml.chart.CTChartSpace;
import org.docx4j.dml.spreadsheetdrawing.CTDrawing;
import org.docx4j.dml.spreadsheetdrawing.CTMarker;
Expand Down Expand Up @@ -278,7 +279,15 @@ public void clearWorkbook() {
throw new ReportFormattingException("An error occurred while clearing docx4j workbook", e);
}
}
workbook.getDefinedNames().getDefinedName().clear();
}

/**
* Method clears defined names associated with band data and leaves all other defined names in the workbook
*/
public void clearBandDefinedNames(BandData rootBand) {
workbook.getDefinedNames().getDefinedName().removeIf(
ctDefinedName -> rootBand.findBandRecursively(ctDefinedName.getName()) != null
);
}

public static class SheetWrapper {
Expand Down

0 comments on commit bbad95b

Please sign in to comment.