2012-01-15 36 views

回答

6

你可以把staticText元素沒有textField元素後面的文本。你應該設置stretchType財產與RelativeToTallestObject值和真正isPrintWhenDetailOverflows財產。

樣本:

<detail> 
    <band height="20" splitType="Stretch"> 
     <staticText> 
      <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/> 
      <box> 
       <leftPen lineWidth="1.0"/> 
       <bottomPen lineWidth="1.0"/> 
       <rightPen lineWidth="1.0"/> 
      </box> 
      <textElement/> 
      <text><![CDATA[]]></text> 
     </staticText> 
     <textField> 
      <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="100" height="20"/> 
      <box> 
       <leftPen lineWidth="1.0"/> 
       <bottomPen lineWidth="1.0"/> 
       <rightPen lineWidth="1.0"/> 
      </box> 
      <textElement/> 
      <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> 
     </textField> 

至於導致你會得到垂直邊框的第二頁。

The text from resulting PDF file with vertical border after using the staticText

結果之前添加第二staticText是(在第二頁的垂直邊界不存在):

The text from resulting PDF file without vertical border before using the staticText

+0

我有嘗試的方法是成功的,但也有每一行重複行。如何避免這一點?這是我的照片http://i.stack.imgur.com/mFIKl.jpg – 2012-10-31 06:58:28

3

更好的辦法是保證,新的細節中的項目(或任何波段)將通過設置在下一頁生成,但不會在文本字段中生成。對於文本字段所在的波段,可以將「分割類型」設置爲「預防」。如果您設置的詳細信息區域和行需要溢出到下一個頁面,它會整行移動到下一個頁面。