在 Jaspersoft Studio 中用虚线创建目录

Create TOC in Jaspersoft studio with dotted lines

我正在尝试在 jasper studio 6.4.3 中创建我的 table 内容。它必须是带点的 TOC,这意味着我需要用点填充标签文本字段和页码文本之间的 space。我当时的解决方案有两个问题。

首先:有半个点可以看,取决于字段中文本的长度

其次:拉伸后我无法让点和页码字段与标签对齐。 点的解决方案是,在两个文本字段后面都有一个静态文本字段,并将文本字段背景设置为 with,以覆盖文本后面的点。

<band height="31" splitType="Stretch">
        <property name="local_mesure_unitheight" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.height" value="px"/>
        <printWhenExpression><![CDATA[$F{level} == 1]]></printWhenExpression>
        <staticText>
            <reportElement style="InhaltsverzeichnisPunkte" mode="Transparent" x="0" y="1" width="440" height="18" uuid="b08b479c-10a8-4d87-8507-4f32fd50004f"/>
            <text><![CDATA[. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .]]></text>
        </staticText>
        <textField isStretchWithOverflow="true">
            <reportElement style="InhaltsverzeichnisPunkte" x="396" y="1" width="45" height="18" uuid="bc43bd36-7466-457c-95e6-384410c05cbe"/>
            <textElement textAlignment="Right"/>
            <textFieldExpression><![CDATA["<style backcolor='white'>"+($V{PAGE_NUMBER} + $F{pageIndex} + 3)+"</style>"]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
            <reportElement style="Formatvorlage Standard (kleiner) + 10 Pt." mode="Transparent" x="0" y="3" width="396" height="15" uuid="b19a02f7-3d3f-4086-86ed-5dc6859e5fd1"/>
            <textElement textAlignment="Left" markup="styled"/>
            <textFieldExpression><![CDATA["<style backcolor='white'>"+$F{label}+"</style>"]]></textFieldExpression>
            <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
        </textField>
    </band>

正如您在图片中看到的那样,页码 6 需要并且点应该与文本字段中的第二行对齐,并且字符 g 之后的点被剪掉了。

你几乎可以实现你想要的:

  • verticalAlignment 将所有文本元素设置为 Bottom
  • stretchType 为 'dotted' staticText 和 'page index' textField 元素设置为 ContainerBottom

像这样:

<band height="39" splitType="Stretch">
<staticText>
    <reportElement stretchType="ContainerBottom" mode="Transparent" x="0" y="1" width="440" height="18" uuid="b08b479c-10a8-4d87-8507-4f32fd50004f"/>
    <textElement verticalAlignment="Bottom"/>
    <text><![CDATA[. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .]]></text>
</staticText>
<textField isStretchWithOverflow="true">
    <reportElement stretchType="ContainerBottom" x="396" y="1" width="45" height="18" uuid="bc43bd36-7466-457c-95e6-384410c05cbe"/>
    <textElement textAlignment="Right" verticalAlignment="Bottom" markup="styled"/>
    <textFieldExpression><![CDATA["<style backcolor='white'>"+($V{PAGE_NUMBER} + $F{pageIndex} + 3)+"</style>"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
    <reportElement mode="Transparent" x="0" y="3" width="396" height="16" uuid="b19a02f7-3d3f-4086-86ed-5dc6859e5fd1">
        <property name="com.jaspersoft.studio.unit.height" value="px"/>
    </reportElement>
    <textElement textAlignment="Left" verticalAlignment="Bottom" markup="styled"/>
    <textFieldExpression><![CDATA["<style backcolor='white'>"+$F{label}+"</style>"]]></textFieldExpression>
    <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
</textField>

输出:

注:

  • 您可能仍会遇到 'cut' 个点,因为文本元素重叠。我想不出其他方法。
  • 我已经通过删除样式和调整元素的高度以正确对齐来调整您的代码。