2013-05-17 2 views
4

Я создал отчет в jrxml. Я уточнял только напечатать детали каждого значения, если один из моих полей заполняется с помощью тега <printWhenExpression> значение вроде так:Удаление пустых записей из отчета Jasper

<textField> 
      <reportElement x="670" y="4" width="105" height="20" isRemoveLineWhenBlank="true"> 
       <printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression> 
      </reportElement> 
      <textElement> 
       <font fontName="Arial" size="10"/> 
      </textElement> 
      <textFieldExpression><![CDATA[$F{value2}]]></textFieldExpression> 

Это работает в фильтрации только соответствующие данные, однако он оставляет меня с большим пустых строк в отчете. Я включил условие isRemoveLineWhenBlank="true", чтобы удалить эти пустые строки из моего отчета. Это взяло мой отчет с 12 страниц до 5, однако, я все еще наблюдаю большое количество пустых строк в отчете.

Здесь приведено изображение экрана моих отчетов в ireport.

enter image description here

А вот скриншот пробега отчета (я гашусь имя моей компании из классов)

enter image description here

Полный отчет JRXML:

<?xml version="1.0" encoding="UTF-8"?> 
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="RIOBridgeReport" pageWidth="1530" pageHeight="842" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="10" rightMargin="5" topMargin="10" bottomMargin="10"> 
    <property name="ireport.zoom" value="2.0"/> 
    <property name="ireport.x" value="0"/> 
    <property name="ireport.y" value="0"/> 
    <property name="net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.1" value="columnHeader"/> 
    <parameter name="title" class="java.lang.String"/> 
    <parameter name="oneliner" class="java.lang.String"/> 
    <field name="name" class="java.lang.String"> 
     <fieldDescription><![CDATA[id[starts-with(.,'USCS')]]]></fieldDescription> 
    </field> 
    <field name="class" class="java.lang.String"> 
     <fieldDescription><![CDATA[class]]></fieldDescription> 
    </field> 
    <field name="value" class="java.lang.String"> 
     <fieldDescription><![CDATA[constructor-arg/value]]></fieldDescription> 
    </field> 
    <field name="value1" class="java.lang.String"> 
     <fieldDescription><![CDATA[constructor-arg[1]/value]]></fieldDescription> 
    </field> 
    <field name="value2" class="java.lang.String"> 
     <fieldDescription><![CDATA[constructor-arg[2]/value]]></fieldDescription> 
    </field> 
    <variable name="runDate" class="java.lang.String"> 
     <initialValueExpression><![CDATA[new java.text.SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z").format(new java.util.Date())]]></initialValueExpression> 
    </variable> 
    <background> 
     <band splitType="Stretch"/> 
    </background> 
    <title> 
     <band height="53" splitType="Stretch"> 
      <textField isBlankWhenNull="true"> 
       <reportElement x="12" y="12" width="496" height="20"/> 
       <textElement textAlignment="Center"> 
        <font fontName="Arial" size="14" isBold="true"/> 
       </textElement> 
       <textFieldExpression><![CDATA[$P{title} + " - " + $V{runDate}]]></textFieldExpression> 
      </textField> 
      <image> 
       <reportElement x="616" y="0" width="84" height="53"/> 
       <imageExpression><![CDATA["citi_corp_logo.gif"]]></imageExpression> 
      </image> 
      <textField isBlankWhenNull="true"> 
       <reportElement x="12" y="32" width="496" height="20"/> 
       <textElement textAlignment="Center"> 
        <font fontName="Arial" size="10" isBold="true"/> 
       </textElement> 
       <textFieldExpression><![CDATA[$P{oneliner}]]></textFieldExpression> 
      </textField> 
     </band> 
    </title> 
    <columnHeader> 
     <band height="23" splitType="Stretch"> 
      <staticText> 
       <reportElement x="12" y="2" width="85" height="20"/> 
       <textElement> 
        <font fontName="Arial" size="10" isBold="true" isUnderline="false"/> 
       </textElement> 
       <text><![CDATA[Bean Name]]></text> 
      </staticText> 
      <staticText> 
       <reportElement x="228" y="2" width="85" height="20"/> 
       <textElement> 
        <font fontName="Arial" size="10" isBold="true" isUnderline="false"/> 
       </textElement> 
       <text><![CDATA[Class]]></text> 
      </staticText> 
      <staticText> 
       <reportElement x="428" y="2" width="105" height="20"/> 
       <textElement> 
        <font fontName="Arial" size="10" isBold="true" isUnderline="false"/> 
       </textElement> 
       <text><![CDATA[Value]]></text> 
      </staticText> 
      <staticText> 
       <reportElement x="543" y="2" width="105" height="20"/> 
       <textElement> 
        <font fontName="Arial" size="10" isBold="true" isUnderline="false"/> 
       </textElement> 
       <text><![CDATA[Value1]]></text> 
      </staticText> 
      <staticText> 
       <reportElement x="670" y="2" width="105" height="20"/> 
       <textElement> 
        <font fontName="Arial" size="10" isBold="true" isUnderline="false"/> 
       </textElement> 
       <text><![CDATA[Value2]]></text> 
      </staticText> 
     </band> 
    </columnHeader> 
    <detail> 
     <band height="24"> 
      <textField isBlankWhenNull="true"> 
       <reportElement x="12" y="2" width="216" height="20" isRemoveLineWhenBlank="true"> 
        <printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression> 
       </reportElement> 
       <textElement> 
        <font fontName="Arial" size="10"/> 
       </textElement> 
       <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="228" y="2" width="185" height="20"> 
        <printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression> 
       </reportElement> 
       <textElement> 
        <font fontName="Arial" size="10"/> 
       </textElement> 
       <textFieldExpression><![CDATA[$F{class}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="428" y="2" width="105" height="20"> 
        <printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression> 
       </reportElement> 
       <textElement> 
        <font fontName="Arial" size="10"/> 
       </textElement> 
       <textFieldExpression><![CDATA[$F{value}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="543" y="4" width="105" height="20"> 
        <printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression> 
       </reportElement> 
       <textElement> 
        <font fontName="Arial" size="10"/> 
       </textElement> 
       <textFieldExpression><![CDATA[$F{value1}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="670" y="4" width="105" height="20"> 
        <printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression> 
       </reportElement> 
       <textElement> 
        <font fontName="Arial" size="10"/> 
       </textElement> 
       <textFieldExpression><![CDATA[$F{value2}]]></textFieldExpression> 
      </textField> 
     </band> 
    </detail> 
    <noData> 
     <band height="20"> 
      <staticText> 
       <reportElement x="146" y="0" width="200" height="20"/> 
       <textElement textAlignment="Center"> 
        <font fontName="Arial" size="14" isBold="true"/> 
       </textElement> 
       <text><![CDATA[No data found]]></text> 
      </staticText> 
     </band> 
    </noData> 
</jasperReport> 

Как вы видите, в отчете осталось большое количество пробелов. Есть ли способ полностью удалить их или нажать пустые строки в конец отчета.

+0

Можете ли вы опубликовать скриншот вашего проекта отчета (группы с полями) и скриншот сгенерированного отчета? –

+0

@AlexK добавление – Will

ответ

4

Попробуйте разместить все внутри рамки и добавить в рамку «Удалить линию, когда она пуста».

+0

это работает ..... – Abs

1

Вместо isRemoveLineWhenBlank для поля используют свойства полосы детализированного диапазона. Поэтому это условие должно быть указано в свойствах полосы данных printWhenExpression. .

Смежные вопросы