Jasper reports 具有动态内容的文本字段出现僵局

Jasper reports 具有动态内容的文本字段出现僵局,jasper-reports,Jasper Reports,我真的希望有人能对这个布局问题有所了解,因为我已经没有主意了 虽然我认为我的问题与设计有关,即Jasper对待它们的方式(布局),但这里有一些关于应用程序的一般信息 基本上,我们有一个JAVA客户机-服务器应用程序,我们使用Jasper生成一系列报告。Jasper设计由服务器端的servlet处理,并作为jrprint文件发送到客户机,在那里它们被呈现给用户。我们还有一个scriptlet,它可以做一些事情——连接数据等等 我遇到问题的报告的代码片段#1中显示了以下结构 它的数据来自一个工作完美

我真的希望有人能对这个布局问题有所了解,因为我已经没有主意了

虽然我认为我的问题与设计有关,即Jasper对待它们的方式(布局),但这里有一些关于应用程序的一般信息

基本上,我们有一个JAVA客户机-服务器应用程序,我们使用Jasper生成一系列报告。Jasper设计由服务器端的servlet处理,并作为jrprint文件发送到客户机,在那里它们被呈现给用户。我们还有一个scriptlet,它可以做一些事情——连接数据等等

我遇到问题的报告的代码片段#1中显示了以下结构

它的数据来自一个工作完美的SQL查询,所以只有布局困扰着我

在细节中,我有一组文本字段,它们可以可视化一些层次结构,还有一个文本字段可以包含相对大量的文本。我把每一个都装进了一个框架,两个都在另一个框架里

在它们下面,我有另一个框架,可以包含0、1或2个图像(理想情况下)。我最终得到了一份报告,其中包含的页面与附件1中的页面类似

我的目标是让报告页面在上面的框架和图像框架之间没有空格,就像附件2中的一样,当然,文本在上面的框架内。目前,这只有在我去掉冗长的文本后才可能实现

在我看来,问题在于为冗长的文本定义字段。因为我不知道字符串的长度,所以我定义它的高度为13(代码片段#2),这只是一行。由于场的拉伸特性,它可以相应地调节,但通过这样做,它会将图像向下推变行数。那么,有没有办法避免这种破坏设计的“推挤”呢


代码:

代码:


截图:

<band height="245" isSplitAllowed="false"><!-- 245 -->
  <frame>
    <reportElement isRemoveLineWhenBlank="true"
      positionType="Float" width="545" y="0" x="0" height="75"
      stretchType="RelativeToBandHeight">
    </reportElement>

    <box>
      <pen lineColor="black" lineStyle="Solid"
        lineWidth="1" />
    </box>

    <frame>
      <reportElement isRemoveLineWhenBlank="true"
        positionType="FixRelativeToTop" width="200" y="0" x="55"
        height="75" stretchType="RelativeToTallestObject"/>

      <box>
        <pen lineColor="green" lineStyle="Solid"
          lineWidth="3" />
      </box>

      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true" evaluationGroup="Ebene2">
        <reportElement x="0" y="0" width="200"
          height="13" positionType="Float" isRemoveLineWhenBlank="true"
          isPrintInFirstWholeBand="true">
          <printWhenExpression><![CDATA[new Boolean(  ($F{AnlagenEbeneOfSchaden}).intValue()==1 )]]></printWhenExpression>
        </reportElement>

        <textElement>
          <font fontName="Arial" size="10"
            isBold="true" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica-Bold"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 1)]]></textFieldExpression>
      </textField>

      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true" evaluationGroup="Ebene2">
        <reportElement x="15" y="0" width="185"
          height="13" mode="Opaque" positionType="Float"
          isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" />
        <textElement>
          <font fontName="Arial" size="10"
            isBold="true" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica-Bold"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 2)]]></textFieldExpression>
      </textField>
      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true" evaluationGroup="Ebene3">
        <reportElement mode="Opaque" x="30" y="15"
          width="170" height="13" positionType="Float"
          isRemoveLineWhenBlank="true" />
        <textElement>
          <font fontName="Arial" size="10"
            isBold="false" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 3)]]></textFieldExpression>
      </textField>

      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true">
        <reportElement mode="Opaque" x="45" y="30"
          width="155" height="13" positionType="Float"
          isRemoveLineWhenBlank="true" />
        <textElement>
          <font fontName="Arial" size="10"
            isBold="false" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 4)]]></textFieldExpression>
      </textField>
      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true">
        <reportElement mode="Opaque" x="60" y="45"
          width="140" height="13" positionType="Float"
          isRemoveLineWhenBlank="true" />
        <textElement>
          <font fontName="Arial" size="10"
            isBold="false" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 5)]]></textFieldExpression>
      </textField>
      <textField isStretchWithOverflow="true" pattern=""
        isBlankWhenNull="true">
        <reportElement mode="Opaque" x="75" y="60"
          width="125" height="13" positionType="Float"
          isRemoveLineWhenBlank="true" />
        <textElement>
          <font fontName="Arial" size="10"
            isBold="false" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[((alwin2Scriptlet)$P{REPORT_SCRIPTLET}).getStrukturBezMitStandOrtEbeneDB($F{Strukturcode1}, 6)]]></textFieldExpression>
      </textField>
    </frame>

    <textField isStretchWithOverflow="true" pattern=""
      isBlankWhenNull="true">
      <reportElement mode="Opaque" x="30" y="1" width="20"
        height="13" isRemoveLineWhenBlank="true" />
      <textElement>
        <font fontName="Arial" size="10" isBold="true"
          isItalic="false" isUnderline="false" isStrikeThrough="false"
          pdfFontName="Helvetica" pdfEncoding="CP1252"
          isPdfEmbedded="false" />
      </textElement>
      <textFieldExpression class="java.lang.Integer"><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
    </textField>
    <textField isStretchWithOverflow="true" pattern=""
      isBlankWhenNull="true">
      <reportElement mode="Opaque" x="515" y="1"
        width="20" height="13" isRemoveLineWhenBlank="true" />
      <textElement textAlignment="Right">
        <font fontName="Arial" size="11" isBold="true"
          isItalic="false" isUnderline="false" isStrikeThrough="false"
          pdfFontName="Helvetica-Bold" pdfEncoding="CP1252"
          isPdfEmbedded="false" />
      </textElement>
      <textFieldExpression class="java.lang.String"><![CDATA[$F{Bewertung}]]></textFieldExpression>
    </textField>
    <frame>
      <reportElement isRemoveLineWhenBlank="true"
        positionType="FixRelativeToTop" width="240" y="0" x="255"
        height="15" stretchType="RelativeToTallestObject" />

      <box>
        <pen lineColor="red" lineStyle="Solid"
          lineWidth="3" />
      </box>

      <textField isStretchWithOverflow="true"
        isBlankWhenNull="true">
        <reportElement mode="Opaque" x="0" y="1"
          width="240" height="13" isRemoveLineWhenBlank="true"
          isPrintWhenDetailOverflows="true"  />
        <textElement verticalAlignment="Top">
          <font fontName="Arial" size="10"
            isBold="false" isItalic="false" isUnderline="false"
            isStrikeThrough="false" pdfFontName="Helvetica"
            pdfEncoding="CP1252" isPdfEmbedded="false" />
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA[$F{SCHADENGRUPPE} + ($F{SCHADENBESCHREIBUNG}!=null?$F{SCHADENBESCHREIBUNG}:"")+" ["+$F{SCHADENNR}+"]"]]></textFieldExpression>
      </textField>
    </frame>
  </frame>
  <frame>
    <reportElement isRemoveLineWhenBlank="true"
      positionType="Float" width="545" y="76" x="0" height="155">
      <printWhenExpression><![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) || (!($F{BILD2_FILE} == null)) )]]></printWhenExpression>
    </reportElement>
    <!--        <box padding="5">
      <pen lineColor="black" lineStyle="Solid"
      lineWidth="3" />
      </box>
    -->
    <image vAlign="Top" hAlign="Center">
      <reportElement positionType="Float" x="303" y="0"
        width="212" height="145" isPrintWhenDetailOverflows="true"
        isRemoveLineWhenBlank="true">
        <printWhenExpression><![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) && ($F{BILD2_FILE} == null) )]]></printWhenExpression>
      </reportElement>
      <graphicElement />
      <imageExpression class="java.awt.Image"><![CDATA[$F{BILD1_FILE}]]></imageExpression>
    </image>
    <image vAlign="Top" hAlign="Center">
      <reportElement positionType="Float" x="303" y="0"
        width="212" height="145" isPrintWhenDetailOverflows="true"
        isRemoveLineWhenBlank="true">
        <printWhenExpression><![CDATA[new Boolean( (!($F{BILD2_FILE} == null)) && ($F{BILD1_FILE} == null) )]]></printWhenExpression>
      </reportElement>
      <graphicElement />
      <imageExpression class="java.awt.Image"><![CDATA[$F{BILD2_FILE}]]></imageExpression>
    </image>
    <image vAlign="Top" hAlign="Center">
      <reportElement positionType="Float" x="70" y="0"
        width="212" height="145" isPrintWhenDetailOverflows="true"
        isRemoveLineWhenBlank="true">
        <printWhenExpression><![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) && (!($F{BILD2_FILE} == null)) )]]></printWhenExpression>
      </reportElement>
      <graphicElement />
      <imageExpression class="java.awt.Image"><![CDATA[$F{BILD1_FILE}]]></imageExpression>
    </image>
    <image vAlign="Top" hAlign="Center">
      <reportElement positionType="Float" x="303" y="0"
        width="212" height="145" isPrintWhenDetailOverflows="true"
        isRemoveLineWhenBlank="true">
        <printWhenExpression><![CDATA[new Boolean( (!($F{BILD2_FILE} == null)) && (!($F{BILD1_FILE} == null)) )]]></printWhenExpression>
      </reportElement>
      <graphicElement />
      <imageExpression class="java.awt.Image"><![CDATA[$F{BILD2_FILE}]]></imageExpression>
    </image>
  </frame>

  <line>
    <reportElement positionType="Float" mode="Opaque" x="0"
      y="240" width="525" height="1" />
    <graphicElement pen="Thin" />
  </line>

  <!--
    <frame>
    <reportElement isRemoveLineWhenBlank="true"
    positionType="Float" width="545" y="86" x="0" height="170">
    <printWhenExpression><![CDATA[new Boolean( (!($F{BILD1_FILE} == null) ) || (!($F{BILD2_FILE} == null)) )]]></printWhenExpression>
    </reportElement>
    <box>
    <pen lineColor="black" lineStyle="Solid"
    lineWidth="1" />
    </box>
    </frame>
  -->
</band>
<textField isStretchWithOverflow="true"
  isBlankWhenNull="true">
  <reportElement mode="Opaque" x="0" y="1"
    width="240" height="13" isRemoveLineWhenBlank="true"
    isPrintWhenDetailOverflows="true"  />
  <textElement verticalAlignment="Top">
    <font fontName="Arial" size="10"
      isBold="false" isItalic="false" isUnderline="false"
      isStrikeThrough="false" pdfFontName="Helvetica"
      pdfEncoding="CP1252" isPdfEmbedded="false" />
  </textElement>
  <textFieldExpression class="java.lang.String"><![CDATA[$F{SCHADENGRUPPE} + ($F{SCHADENBESCHREIBUNG}!=null?$F{SCHADENBESCHREIBUNG}:"")+" ["+$F{SCHADENNR}+"]"]]></textFieldExpression>
</textField>