BilalSiddiquiによるJasperReportDevelopmentクックブックという本から、私のようなレポートデザイナーにとって非常に役立つと思うJasperレポートでのスタイルの使用に関する私の学習を共有したいと思います。私はこの本が好きで、次のようなさまざまな方法でスタイルを示すことがわかりました。
<template><![CDATA["C:\\ BigBoldRedTemplate.jrtx"]]></template>
ステップ2。スタイルテンプレートを使用してレポート要素にスタイルを適用するたびに、次のように<reportElement>
タグが作成されます。
//style applied to a rectangle
<rectangle radius="10">
<reportElement style="BigBoldRed" mode="Transparent" x="0" y="0" width="555" height="44"/>
</rectangle>
//style applied to a the text field
<staticText>
<reportElement style="BigBoldRed" x="0" y="0" width="555" height="66"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Monthly Customer Invoices]]></text>
</staticText>
- レポートで内部スタイルと再利用可能なスタイルを混在させる
- HTMLの力を使用してレポートのスタイルを設定する
たとえば、テキストフィールドにHTMLタグ(つまり<li>
)を含む次の式があり、HTMLタグをレポートデザインで機能させるには、次のようにします。
"<li>"+"Invoice # "+$F{InvoiceID}+", "+
$ F {CustomerName}+"は"+$ F{InvoicePeriod}+"で"+$ F {ProductName} + "を購入しました(請求書の値:\ $" + $ F {InvoiceValue} + ")" + "
解決策は簡単です。テキストフィールドの「Markup」プロパティを「Styled」に設定するだけです。
この投稿のJasperReportsクックブックからコードチャンクをコピーする許可を著者から取得しました。