jasperreports导出xlsx列头重复

导出xlsx文件表头重复怎么办?
使用的是JRXlsxExporter.exportReport;
关键代码如下

SimpleOutputStreamExporterOutput simpleOutputStreamExporterOutput = new SimpleOutputStreamExporterOutput(outputStream);
Exporter exporter = new JRXlsxExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));    
exporter.setExporterOutput(simpleOutputStreamExporterOutput);
SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
configuration.setOnePagePerSheet(false);
configuration.setIgnoreGraphics(false);
configuration.setRemoveEmptySpaceBetweenRows(true);
configuration.setIgnorePageMargins(true);
configuration.setDetectCellType(true);
configuration.setWhitePageBackground(false);
exporter.setConfiguration(configuration);
exporter.exportReport();
outputStream.close();
out.clear();
out = pageContext.pushBody();

导出后异常效果如图

img


表头重复了。
旧版本使用
parametMap.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE);//忽略分页
或者设计器中设置IGNORE_PAGINATION打勾
来解决本问题。
但是换成了上面的导出后,就表头重复了。

表头重复可能是由于在报表模板中设置了重复表头的选项,而导出设置中没有设置对应的选项导致的。试一试这个配置,如果不行再沟通

configuration.setCollapseRowSpan(false);

这个配置选项会关闭行合并功能,从而避免表头重复

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^