You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jasper报表导出HTML时stretchType="ElementGroupHeight"失效(无空格场景)

Jasper报表HTML导出时无空格内容的stretchType属性失效问题

将Jasper报表导出为HTML格式时,当内容无空格,stretchType="ElementGroupHeight"属性无法正常生效;但导出为PDF格式时该功能表现正常。

Jasper报表代码

<textField isStretchWithOverflow="true" >
    <reportElement key="" stretchType="ElementGroupHeight" x="406" y="0" width="132" height="20" forecolor="#050505" uuid="7717f0db-9ebe-4fef-9465-370d96121dc2"/>
    <box padding="2">
        <pen lineWidth="0.0"/>
        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
    </box>
    <textElement>
        <font size="9"/>
    </textElement>
    <textFieldExpression><![CDATA[$F{days} != null?$F{days}+" day(s) ago" :"-"]]></textFieldExpression>
</textField>

Java导出代码

HtmlExporter exporter = new HtmlExporter();
exporter.setExporterOutput(new SimpleHtmlExporterOutput(out));
exporter.setExporterInput(new SimpleExporterInput(print));
exporter.exportReport();

效果对比

  • HTML报表未按高度拉伸:当内容无空格时,文本框未随内容高度拉伸,内容出现截断,无法完整显示。
  • PDF报表功能正常:文本框可正常随内容高度拉伸,内容完整显示,符合预期效果。

内容的提问来源于stack exchange,提问作者Talha Asif

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 12:33:17