Hi everyone,
I recently created a GitHub issue regarding a problem with uploading Word (DOCX) templates in Jmix Reports.
Problem Summary
After uploading a new Word template to an existing report and trying to download it again later, the resulting DOCX file appears to be corrupted and cannot be opened in Microsoft Word.
Temporary Workaround
To temporarily fix the issue, I’ve overridden the initTemplateEditor
method in ReportTemplateDetailView
and commented out the following code:
// templateFileEditor.addValueChangeListener(e -> {
// reportTemplate.setContent(e.getValue().getBytes(StandardCharsets.UTF_8));
// });
With this change, uploading and downloading DOCX templates seems to work again.
Question
This workaround seems to solve the problem for now, but I assume it might lead to side effects elsewhere. Is there a cleaner or recommended workaround until a fix is provided in the framework?
Thanks in advance!
Edit:
Maybe that is more correct?
...
if (hasHtmlCsvTemplateOutput(outputType)) {
String templateContent = new String(reportTemplate.getContent(), StandardCharsets.UTF_8);
templateFileEditor.setValue(templateContent);
templateFileEditor.addValueChangeListener(e -> {
reportTemplate.setContent(e.getValue().getBytes(StandardCharsets.UTF_8));
});
}
...