如何在Jasper报表中订阅字段

6

如何使字段显示为下标或在文本基线下显示字段。
当我使用USPSIMBStandard字体时,应打印的信息跳到上方或隐藏文本字段的上部分。当我将信息的任何部分复制到Word中并进行下标处理时,它会正确地显示。


您可以使用其他文本来显示SubScript。 - Sharad
讽刺的是我只能使用USPSIMBStandard。 - fahad
1个回答

10

您可以使用样式标记来解决此任务,<sub>标记用于下标文本,<sup>标记用于上标文本。

示例

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="test_markup" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="NoDataSection" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c3c991dc-b3f2-4d45-b429-821e33c5324d">
    <title>
        <band height="55" splitType="Stretch">
            <textField isStretchWithOverflow="true">
                <reportElement uuid="6b947a69-22bb-4a63-9e56-cacc75747df0" x="115" y="17" width="324" height="20"/>
                <textElement markup="styled">
                    <font isUnderline="false" isStrikeThrough="false"/>
                </textElement>
                <textFieldExpression><![CDATA["Text with<sup>superscript</sup> \nText with<sub>subscript</sub>"]]></textFieldExpression>
            </textField>
        </band>
    </title>
</jasperReport>

结果将通过iReport预览显示: enter image description here 注意事项: - 可在Style a text field in JasperReports帖子中找到有关使用markup的示例。 - 有关markup的更多信息可在此处查找

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接