1

JasperReports で目次を作成する必要があります。私はすでにこれを達成していますが、TOC の行で何もできません。

現在、それらは静的な幅を持っています:

Chapter 1          ........ 2
Long Chapter Name  ........ 3
End                ........ 4

チャプター名の幅まで点線を引き延ばしたい。ここみたいに:

Chapter 1 ................. 2
Long Chapter Name ......... 3
End ....................... 4

これどうやってするの?JRには「パディング」機能がありますか、それともこのタスク用のスクリプトレットを作成する必要がありますか? ありがとう!

PS私はジャスパーレポート5.0.1を使用しています

4

1 に答える 1

1

これはあまりきれいな方法ではありませんが、テキスト ボックスに多くのドットを描画し、フレームを使用して末尾を非表示にして、ページ番号を書き込めるようにします。

<?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="table of content" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="df5894b6-0e62-4082-bdb8-3f0a1b26a2f4">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <queryString>
        <![CDATA[SELECT
     1 AS page,
     'test' AS title
FROM
     "account" account
Union
SELECT
     4 AS page,
     'chapter 2' AS title
FROM
     "account" account
Union
SELECT
     20 AS page,
     'chapter 3: hello' AS title
FROM
     "account" account]]>
    </queryString>
    <field name="page" class="java.lang.Integer"/>
    <field name="title" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="20" splitType="Stretch">
            <staticText>
                <reportElement uuid="2e81fd32-3b8d-4b98-b96d-6409afb8d16f" x="0" y="0" width="555" height="20"/>
                <textElement>
                    <font isBold="true" isStrikeThrough="false"/>
                </textElement>
                <text><![CDATA[Table of content]]></text>
            </staticText>
        </band>
    </title>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="20" splitType="Stretch">
            <textField>
                <reportElement uuid="c8707508-946a-48ae-ae75-61810003e1db" x="0" y="0" width="555" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{title}+"  .............................................................................................................................."]]></textFieldExpression>
            </textField>
            <frame>
                <reportElement uuid="4040d203-6b49-4da2-8bcf-f3d6d48c7fd7" mode="Opaque" x="341" y="0" width="214" height="20"/>
            </frame>
            <textField>
                <reportElement uuid="472f8f95-fdea-4cd9-b3a5-a1b9b66a8c44" mode="Opaque" x="321" y="0" width="20" height="20"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{page}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>
于 2013-03-12T14:30:59.707 に答える