gpt4 book ai didi

java - JasperReports 导出到 excel 自动大小列

转载 作者:搜寻专家 更新时间:2023-10-31 19:33:14 24 4
gpt4 key购买 nike

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

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="templ" language="groovy" pageWidth="1100" pageHeight="1400" columnWidth="1060" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryNewPage="true" isSummaryWithPageHeaderAndFooter="true" uuid="683fcccd-cd5a-4e1d-a085-b49c54c13fff">
<property name="ireport.zoom" value="1.2100000000000029"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
<property name="net.sf.jasperreports.print.keep.full.text" value="true"/>
<property name="net.sf.jasperreports.export.xls.wrap.text" value="false"/>
<property name="net.sf.jasperreports.export.xls.auto.fit.row" value="true"/>
<property name="net.sf.jasperreports.export.xls.auto.fit.column" value="true"/>
<queryString language="SQL">
<![CDATA[]]>
</queryString>
</jasperReport>

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 .

例如第一列必须是“客户编号”而不是“客户”

最佳答案

以下属性在报表级别不起作用:

<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" width="100" height="20">
<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

关于java - JasperReports 导出到 excel 自动大小列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23987944/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com