JasperReports导出为ex​​cel auto size columns

 l清笛l 发布于 2023-01-12 11:06

我有JRXlsExporter的问题.自动调整属性无法正常工作.这是我的jrxml:



    
    
    
    
    
    
    
    
    
        
    

Java代码:

excelExporter.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
excelExporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, outputStream);
excelExporter.setParameter(JRXlsExporterParameter.MAXIMUM_ROWS_PER_SHEET, 65536);
excelExporter.setParameter(JRXlsExporterParameter.IS_IGNORE_CELL_BORDER, Boolean.FALSE);
excelExporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
excelExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
excelExporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_IMAGE_BORDER_FIX_ENABLED, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_IGNORE_GRAPHICS, Boolean.FALSE);

并输出结果: resultFile.

例如,第一列必须是"客户编号"而不是"客户编号"

1 个回答
  • 以下属性不适用于报告级别:

    <property name="net.sf.jasperreports.export.xls.auto.fit.row" value="true"/>
    <property name="net.sf.jasperreports.export.xls.auto.fit.column" value="true"/>
    

    你必须把它们放在报告元素上(即):

            <staticText>
                <reportElement x="0" y="100"  >
                    <property name="net.sf.jasperreports.export.xls.auto.fit.row" value="true"/>
                    <property name="net.sf.jasperreports.export.xls.auto.fit.column" value="true"/>
                </reportElement>
                <textElement/>
                <text><![CDATA[Your Static Text]]></text>
            </staticText>
    

    另外我建议你尝试使用net.sf.jasperreports.export.xls.column.width属性,这更有用.参考:http://jasperreports.sourceforge.net/config.reference.html

    2023-01-12 11:09 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有