导出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();
导出后异常效果如图
表头重复可能是由于在报表模板中设置了重复表头的选项,而导出设置中没有设置对应的选项导致的。试一试这个配置,如果不行再沟通
configuration.setCollapseRowSpan(false);
这个配置选项会关闭行合并功能,从而避免表头重复
不知道你这个问题是否已经解决, 如果还没有解决的话: