cuba-platform / yarg

Yet Another Report Generator - CUBA Platform reporting engine
https://www.cuba-platform.com
Apache License 2.0
239 stars 75 forks source link

docx template containing a table generates java.lang.NullPointerException #175

Open distributev opened 1 year ago

distributev commented 1 year ago

Using the attached docx template

template-col0col1-table.docx

which contains a basic table

I get

Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Exception exporting package at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:106) at org.docx4j.Docx4J.toFO(Docx4J.java:712) at org.docx4j.Docx4J.toPDF(Docx4J.java:741) at com.haulmont.yarg.formatters.impl.DocxFormatter.saveAndClose(DocxFormatter.java:151) ... 29 more Caused by: java.lang.NullPointerException: Cannot invoke "org.docx4j.wml.Style.getPPr()" because "expressStyle" is null at org.docx4j.convert.out.common.preprocess.ParagraphStylesInTableFix$StyleRenamer.getCellPStyle(ParagraphStylesInTableFix.java:250) at org.docx4j.convert.out.common.preprocess.ParagraphStylesInTableFix$StyleRenamer.apply(ParagraphStylesInTableFix.java:585) at org.docx4j.convert.out.common.preprocess.ParagraphStylesInTableFix$StyleRenamer.walkJAXBElements(ParagraphStylesInTableFix.java:625)

Environment

yarg 2.2.14

Windows 10

Description of the bug or enhancement


Map<String, Object> variablesData = new HashMap<String, Object>();

variablesData.put("col0", "data0");
variablesData.put("col1", "data1");

final String TEMPLATE_DOCX_WORDPAD_PATH = "src/test/resources/input/external-libraries/template-col0col1-table.docx";

String outputFilePath = TestsUtils.TESTS_OUTPUT_FOLDER + "/YargTest/generatePDFTemplateDocxTable/output.pdf";

generateDocument(outputFilePath, TEMPLATE_DOCX_WORDPAD_PATH, variablesData);