2012-01-15 38 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

更好的办法是保证,新的细节中的项目(或任何波段)将通过设置在下一页生成,但不会在文本字段中生成。对于文本字段所在的波段,可以将“分割类型”设置为“预防”。如果您设置的详细信息区域和行需要溢出到下一个页面,它会整行移动到下一个页面。