表组件中的iReport单元跨越 [英] iReport Cell Spanning in Table Component
问题描述
我正在使用iReport来显示表中 net.sf.jasperreports.engine.data.JRTableModelDataSource
的数据。我正在使用TableModelDataSource,因为我必须使用Java作为数据源。
I'm using the iReport with to display data from a net.sf.jasperreports.engine.data.JRTableModelDataSource
in a table. I'm using the TableModelDataSource, because I have to use Java as a data source.
我现在得到以下代码,工作正常:
I now got the following code, which is working fine:
<?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="controltest" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.3310000000000022"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="276"/>
<property name="ireport.callouts" value="##Wed Dec 05 08:22:05 CET 2012"/>
<subDataset name="plantsResultTable">
<field name="COLUMN_0" class="java.lang.String"/>
<field name="COLUMN_1" class="java.lang.String"/>
<field name="COLUMN_2" class="java.lang.String"/>
<field name="COLUMN_3" class="java.lang.String"/>
<field name="COLUMN_4" class="java.lang.String"/>
<field name="COLUMN_5" class="java.lang.String"/>
<field name="readActualSupply" class="java.lang.String"/>
<group name="supplyGroup">
<groupExpression><![CDATA[$F{readActualSupply}]]></groupExpression>
</group>
</subDataset>
<field name="remotelyControlledSupply" class="java.lang.String"/>
<field name="thirdPartyAccess" class="java.lang.String"/>
<field name="plantsResultTable" class="net.sf.jasperreports.engine.JRDataSource"/>
<background>
<band/>
</background>
<pageHeader>
<band/>
</pageHeader>
<detail>
<band height="675">
<frame>
<reportElement x="0" y="250" width="555" height="239"/>
<componentElement>
<reportElement key="table 2" x="0" y="17" width="555" height="222"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="plantsResultTable">
<dataSourceExpression><![CDATA[$F{plantsResultTable}]]></dataSourceExpression>
</datasetRun>
<jr:column width="90">
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[COLUMN_0]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20">
<textField pattern="">
<reportElement x="0" y="0" width="90" height="20">
<printWhenExpression><![CDATA[$V{supplyGroup_COUNT} == 1]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{COLUMN_0}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[COLUMN_1]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{COLUMN_1}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[COLUMN_2]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{COLUMN_2}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[COLUMN_3]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{COLUMN_3}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[COLUMN_4]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{COLUMN_4}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[COLUMN_5]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{COLUMN_5}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</frame>
</band>
</detail>
<columnFooter>
<band/>
</columnFooter>
<pageFooter>
<band/>
</pageFooter>
<summary>
<band/>
</summary>
</jasperReport>
我现在需要知道的是
- 有没有办法垂直居中COLUMN_0值(将垂直对齐设置为center)。如果$ V {supplyGroup_COUNT} == $ V {supplyGroup_SIZE} / 2 ,我想它必须像
一样。我有实际下显示的表格,但我希望它动态地看起来像目标。
- 有没有办法打印另一个如果表具有分页符,则为COLUMN_0值。这是从第1页开始的表格,并在第2页结束。我可以在第1页和第2页打印COLUMN_0值吗?我放了
< printWhenExpression><![CDATA [$ V {supplyGroup_COUNT} == 1 || $ P {hasPageBreak} .equals(1))]]>< / printWhenExpression>
到我的表的textField,但编译器抱怨无法找到参数hasPageBreak。目前我只计算表格中的项目,如果$ V {supplyGroup_COUNT} == 20并且是否有新页面,则会显示另一个文本。
- Is there a way to center the COLUMN_0 value vertically (set vertical alignment to "center"). I guess it's got to go by sth like
if $V{supplyGroup_COUNT} == $V{supplyGroup_SIZE}/2
. I have the table shown under "actual", but I want it dynamically to look like "target". - Is there a way to print another COLUMN_0 value if the table has a page break. That is the table begins on page 1 and breaks onto page 2 ending there. Can I print a COLUMN_0 value on page 1 and on page 2? I put an
<printWhenExpression><![CDATA[$V{supplyGroup_COUNT} == 1 || $P{hasPageBreak}.equals("1"))]]></printWhenExpression>
to my table's textField, but the compiler complains about not being able to find the parameter hasPageBreak. At the moment I just count the items in my table and put another "text" visible if $V{supplyGroup_COUNT} == 20 and if there is a new page.
3.有没有办法强迫在一定数量的物品后打破一张桌子?我在表格后面有一些文字。我想总是至少有一部分(结尾)和下面的文字。或者我必须使用两个单独的表?
3. Is there a way to force a table to break after a certain amount of items? I have some text that follows the table. I'd like to always have at least a part (the end) of the table together with the following text. Or do I have to use two separate tables?
推荐答案
1)是的,您可以垂直对齐表格单元格内容
1) Yes you can vertically align table cell contents
<textElement verticalAlignment="Middle"/>
我使用的是样式
<style name="table_TD" vAlign="Middle" />
我不确定其他两个(欢迎捐款)
I'm not certain about the other two (contributions welcome)
2)isReprintHeaderOnEachPage适用于组头但是我不确定表是什么?
(我经常使用减少子报告代替表。)
2) isReprintHeaderOnEachPage works for group headers but I'm not sure about for tables? (I often use a cut down subreport in place of a table.)
3)拆分类型可能有所帮助,但如果某些文字是一个单独的对象,我不相信你可以阻止它成为孤儿
3) Split Type on the band may help but if "some text" is a separate object I don't believe you can stop it from being orphaned
希望有所帮助
这篇关于表组件中的iReport单元跨越的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!