Итак, я редактирую старый документ Jasper, который у нас есть в нашей системе. В документе представлен упаковочный лист на основе XML-файла.Добавление полей в отчеты Jasper
Теперь мы хотели бы сделать следующее:
Если есть больше чем 1 статьи линии с одной и той же статье мы хотели бы, чтобы добавить их вверх/объединить их в одну линию.
Я не очень хорошо знаком с iReport, и я сделал несколько небольших изменений, связанных с полем.
Когда я смотрю на Xml документа, я вижу, что вы можете использовать выражения на текстовых полях, содержащих некоторый код. Я думаю, мне нужно будет написать код для группы, представляющей строки статьи, правильно?
Ниже XML часть статьи линии:
<detail>
<band height="38" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="textField-19_1" style="column_field_small" x="228" y="2" width="264" height="12" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{articleDescription}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="textField-20_2" style="column_field_small" x="5" y="2" width="222" height="12" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{articleCode}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-31_5" style="sub_column_header_small" x="229" y="14" width="39" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{CWjp.Quantity}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-32_6" style="sub_column_header_small" x="272" y="14" width="24" height="12"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{CWjp.Pack}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-33_7" style="sub_column_header_small" x="415" y="14" width="52" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{CWjp.Grossweight}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-34_8" style="sub_column_header_small" x="469" y="14" width="61" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{CWjp.Nettweight}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
<reportElement key="textField-21_3" style="sub_column_field_small" x="490" y="26" width="40" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{finalNetWeight}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
<reportElement key="textField-22_4" style="sub_column_field_small" x="427" y="26" width="40" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{finalGrossWeight}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="textField-23_5" style="sub_column_field_small" x="272" y="26" width="24" height="12"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{finalPackageCode}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="###0" isBlankWhenNull="true">
<reportElement key="textField-24_6" style="sub_column_field_small" x="228" y="26" width="40" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{finalQuantity}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="textField-23_5" style="sub_column_field_small" x="300" y="26" width="80" height="12"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[($F{serialCode} != null && $F{serialCode}.length() > 0 ? $F{serialCode} :
($F{customersPalletCode} != null && $F{customersPalletCode}.length() > 0 ? $F{customersPalletCode} :
($F{lotCode} != null && $F{lotCode}.length() > 0 ? $F{lotCode} : "")))]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-32_6" style="sub_column_header_small" x="300" y="14" width="80" height="12">
<printWhenExpression><![CDATA[new Boolean(1==2)]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{CWjp.SerPltLotCode}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-32_6" style="sub_column_header_small" x="380" y="26" width="43" height="12"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["(" + ($F{serialCode} != null && $F{serialCode}.length() > 0 ? $R{CWjp.Serial} :
($F{customersPalletCode} != null && $F{customersPalletCode}.length() > 0 ? $R{CWjp.Pallet} :
($F{lotCode} != null && $F{lotCode}.length() > 0 ? $R{CWjp.Lot1} : "")))
+ ")"]]></textFieldExpression>
</textField>
</band>
</detail>
Я прочитал статью о группировке. Насколько я понимаю, это ставит «строки статей» в группе, чтобы я мог сделать выражение, сортируя их или как это работает? В документе действительно не объясняется, как работать с ними, только реализуя их. Некоторые примеры помогут мне в этом. К сожалению, я не могу найти многого в google ect. –
[Здесь] (https://drive.google.com/file/d/0B5RlXDFsoD4pTGpzRkxTR3FCV0U/view?usp=sharing) представляет собой примерный отчет, в котором используется примерная база данных iReports, чтобы вы могли протестировать ее, данные групп отчетов по shipcountry (обратите внимание, что shipcountry на первом месте в порядке заказа). –