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
相关产品推荐
相关产品推荐

