Skip to content

Commit

Permalink
Fixed setup of defined names
Browse files Browse the repository at this point in the history
  • Loading branch information
Desire456 committed Jul 1, 2021
1 parent ed03199 commit 2ce6d99
Show file tree
Hide file tree
Showing 2 changed files with 8 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.excludeDefinedNames(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,12 @@ public void clearWorkbook() {
throw new ReportFormattingException("An error occurred while clearing docx4j workbook", e);
}
}
workbook.getDefinedNames().getDefinedName().clear();
}

public void excludeDefinedNames(BandData rootBand) {
workbook.getDefinedNames().getDefinedName().removeIf(
ctDefinedName -> rootBand.findBandRecursively(ctDefinedName.getName()) != null
);
}

public static class SheetWrapper {
Expand Down

0 comments on commit 2ce6d99

Please sign in to comment.