2

さまざまなデータ セットを表示するさまざまなテーブルを含むレポートを生成しています。多くの場合、テーブルは 2 ページ目または 3 ページ目に流れます。テーブル ヘッダーを繰り返す方法を知っている人はいますか?

データがランダムな長さであるため、レコード数を使用してヘッダー情報を挿入するタイミングを決定することはできません。そのため、ラップされたテキストを含むレコードでは、ページで 10 行を消費する可能性があります。テーブル ヘッダーを変数として保存して を使用しようとしましたが、各ページの上部に最後のテーブルのヘッダーが表示されます。

問題を説明するためのサンプル コードを次に示します。

<cfoutput>
<cfdocument format="PDF" name="TestDetailReport" marginBottom = "1" marginLeft = ".3" marginRight = ".3" marginTop = ".5" orientation="landscape">
    <cfdocumentsection name = "TA Overview" >
        <cfdocumentitem type = "header">
            <table width="100%">
                <tr>
                    <td width="40%">Generated by:</td>
                    <td width="60%" align="left">cfdocumentitem type = "header"</td>
                </tr>
            </table>
        </cfdocumentitem>

        <!--- There will be several sections like this, each with thier own header --->
        <body style="margin: 0px">
            <table style="width:100%;">
                <!-- table header to be repeated on each PDF page -->
                <thead align="left" style="display: table-header-group">
                    <tr>
                        <td colspan="2" style=" text-align:center;color:red">Make the header of this section repeat when the table goes into the next page</td>
                    </tr>
                    <tr>
                        <td style="text-align:center;color:red">Row Number</td>
                        <td style="text-align:center;color:red">This column contains text of random length</td>
                    </tr>
                </thead>
                <!-- table body -->
                <tbody>
                    <cfloop from="1" to="50" index="Index">
                    <tr style="border-bottom:thin;">
                        <td>Row #Index#</td>
                        <td><cfloop from="0" to="#RandRange(1, 50)#" index="randomText">#Index# blah </cfloop></td>
                    </tr>
                    </cfloop>
                </tbody>
            </table>
        </body>

        <cfdocumentitem type = "footer">
            <table width="100%">
                <tr>
                    <td width="12%">Generated by:</td>
                    <td width="13%" align="left">#cgi.auth_user#</td>
                    <td width="50%" rowspan="3" align="left">img src="file:///#ExpandPath('logo.gif')#"</td>
                    <td width="25%" rowspan="3" align="justify">Printed Copy as Part of Prepbook is a Controlled Document. All Other Copies are Uncontrolled.</td>
                </tr>
                <tr>
                    <td>Date:</td>
                    <td align="left">#DateFormat(now(), "medium")#</td>
                    <!--- <td align="right"></td> --->
                </tr>
                <tr>
                    <td>Page:</td>
                    <td align="left">#cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</td>
                    <!--- <td align="right"></td> --->
                </tr>

            </table>
        </cfdocumentitem>
    </cfdocumentsection>
</cfdocument>

4

3 に答える 3

1

いくつかのソリューション

  • n 個を超えるレコードがテーブルにある場合にテーブル ヘッダーを再度出力するロジックを作成します。これは良い解決策ではありません。私は常に、pdf レポートに cfdocument を使用することをスキップしますが、それは可能です。まず、cfdocument で html の問題に直面します。
  • より良い解決策は、ColdFusion Builder を使用することです。
  • 最善の解決策は、ColdFusion Report Builder の代替手段を使用することかもしれませんが、 すべてをセットアップして実行するには時間がかかります。

レポート ビルダー シナリオを使用することにした場合は、おそらくこれが最適です。ここにあなたがしなければならないことがあります:

ステップ 1 - レポート内の異なるテーブルごとに、coldFusion Builder で cfr (ColdFsuion Report Builder テンプレート ファイル) を作成します。これはとても簡単です。ここにいくつかのドキュメントがあります

ステップ 2 cfreportを使用して「テーブル」ごとに一時的な pdf を生成し、 ddxを使用してこのファイルをマージし、レポートのヘッダーとフッターを追加/設計します。

于 2014-03-10T19:48:51.617 に答える
1

<cfdocumentitem type= "pagebreak>ドキュメントをページに分割する機能を提供します。毎回テーブルヘッダーを再出力する必要があると思います。

見る:

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7758.html

于 2014-03-08T04:58:03.137 に答える