从生成的JasperReports报告中删除Excel格式的软件信息。

问题描述 投票:1回答:1

我正在用JasperReports创建一个XLS报表,代码。

JRXlsExporter exporter = new JRXlsExporter();

exporter.setExporterInput(new SimpleExporterInput(compile(report)));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(stream));

SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();

configuration.setOnePagePerSheet(TRUE);

exporter.setConfiguration(configuration);
exporter.exportReport();

我需要从xls文件元数据中删除软件信息。

运行的结果 exiftool Vinculaciones.xls 命令。

ExifTool Version Number         : 12.00

File Name                       : Vinculaciones.xls

Directory                       : .

File Size                       : 5.5 kB

File Modification Date/Time     : 2020:06:11 15:53:33-05:00

File Access Date/Time           : 2020:06:11 15:53:33-05:00

File Creation Date/Time         : 2020:06:11 15:53:32-05:00

File Permissions                : rw-rw-rw-

File Type                       : XLS

File Type Extension             : xls

MIME Type                       : application/vnd.ms-excel

Software                        : JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3

Warning                         : Truncated property list
java jasper-reports metadata export-to-excel
1个回答
1
投票

尝试添加这些行。

    SimpleXlsExporterConfiguration exportConfig = new SimpleXlsExporterConfiguration();
    exportConfig.setMetadataApplication("");
    exporter.setConfiguration(exportConfig);

这不会删除Software元数据字段,但会给它加上一个空值。 如果你想完全删除该字段,你必须修改扩展exporter代码,例如像这样。

    JRXlsExporter exporter = new JRXlsExporter() {
        @Override
        protected void openWorkbook(OutputStream os) {
            super.openWorkbook(os);
            workbook.getSummaryInformation().removeApplicationName();
        }           
    };
© www.soinside.com 2019 - 2024. All rights reserved.