【问题标题】:Remove Software info from generated with JasperReports report at Excel format从 Excel 格式的 JasperReports 报告中删除软件信息
【发布时间】:2020-06-12 17:34:05
【问题描述】:

我正在使用 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】:

    尝试添加这些行:

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

    这不会删除软件元数据字段,但会为其设置一个空值。如果要完全删除该字段,则必须更改/扩展导出器代码,例如像这样:

        JRXlsExporter exporter = new JRXlsExporter() {
            @Override
            protected void openWorkbook(OutputStream os) {
                super.openWorkbook(os);
                workbook.getSummaryInformation().removeApplicationName();
            }           
        };
    

    【讨论】:

    • 实现是这样的SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration(); SimpleXlsMetadataExporterConfiguration exporterConfiguration = new SimpleXlsMetadataExporterConfiguration(); exporterConfiguration.setMetadataApplication(""); configuration.setOnePagePerSheet(TRUE); configuration.setWhitePageBackground(FALSE); configuration.isRemoveEmptySpaceBetweenRows(); exporter.setConfiguration(configuration); exporter.setConfiguration(exporterConfiguration);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多