<?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="report2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="82a3ce80-bdcd-4d51-8f21-e72b3f438b53">
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFF7FF"/>
</conditionalStyle>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFF7FF"/>
</conditionalStyle>
</style>
<subDataset name="dataset1" uuid="70653a81-8d48-4edd-b72f-20f769f51aea">
<queryString language="SQL">
<![CDATA[SELECT
schooldetails.`ID` AS schooldetails_ID,
schooldetails.`Name` AS schooldetails_Name,
schooldetails.`Boardtype` AS schooldetails_Boardtype,
schooldetails.`Location` AS schooldetails_Location,
schooldetails.`Phone` AS schooldetails_Phone,
schooldetails.`Address` AS schooldetails_Address,
schooldetails.`Additionaldetails` AS schooldetails_Additionaldetails
FROM
`schooldetails` schooldetails]]>
</queryString>
<field name="schooldetails_ID" class="java.lang.Integer"/>
<field name="schooldetails_Name" class="java.lang.String"/>
<field name="schooldetails_Boardtype" class="java.lang.String"/>
<field name="schooldetails_Phone" class="java.lang.String"/>
</subDataset>
<queryString>
<![CDATA[SELECT
schooldetails.`ID` AS schooldetails_ID,
schooldetails.`Name` AS schooldetails_Name,
schooldetails.`Boardtype` AS schooldetails_Boardtype,
schooldetails.`Location` AS schooldetails_Location,
schooldetails.`Phone` AS schooldetails_Phone,
schooldetails.`Address` AS schooldetails_Address,
schooldetails.`Additionaldetails` AS schooldetails_Additionaldetails
FROM
`schooldetails` schooldetails]]>
</queryString>
<field name="schooldetails_ID" class="java.lang.Integer"/>
<field name="schooldetails_Name" class="java.lang.String"/>
<field name="schooldetails_Boardtype" class="java.lang.String"/>
<field name="schooldetails_Location" class="java.lang.String"/>
<field name="schooldetails_Phone" class="java.lang.String"/>
<field name="schooldetails_Address" class="java.lang.String"/>
<field name="schooldetails_Additionaldetails" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement uuid="e15d9fdb-5a73-421d-8059-3e6d84742a43" x="0" y="0" width="555" height="79"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="24" isBold="true"/>
</textElement>
<text><![CDATA[Sample report 2]]></text>
</staticText>
</band>
</title>
<detail>
<band height="114">
<componentElement>
<reportElement uuid="0752ad71-0544-4a92-bc06-666619eada15" key="table 1" style="table 1" x="0" y="0" width="360" height="50"/>
<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="dataset1" uuid="46c3a1a8-1e2b-4ea0-b7ac-5b630657c146">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="99" uuid="b4badcbe-8219-4fcf-978c-b5ff6f2057d0">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement uuid="09f0cb22-b9b2-499a-9e94-0d9edb96e5f8" x="0" y="0" width="99" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[School ID]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="0be272c3-3345-48fd-b90a-a0d0df3bc909" x="0" y="0" width="99" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{schooldetails_ID}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="160" uuid="1f036ef4-d3e4-4113-9084-5530b1e3e8d2">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement uuid="9ef54b86-c6ac-4f0b-8904-ff82ace55d7c" x="0" y="0" width="160" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="6c01ebc8-165d-41da-b632-8b19b67770ac" x="0" y="0" width="160" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{schooldetails_Name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="114" uuid="7561e583-3af8-4799-ac88-2a7e8c164bfa">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement uuid="c500ce42-e32d-4704-9832-52d7413926e3" x="0" y="0" width="114" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Board]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="da078d0e-c6fb-4a3d-a0ed-ea12265cf729" x="0" y="0" width="114" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{schooldetails_Boardtype}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="131" uuid="7842fd3f-e097-4acd-a1ab-a09c0361c23b">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement uuid="c0519344-d25a-4ed9-8970-1acf9e4857ed" x="0" y="0" width="131" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Phone]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="560916c9-e02a-40c9-a7af-a63d285b900a" x="0" y="0" width="131" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{schooldetails_Phone}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
</jasperReport>
如何避免重复两次表格显示?我想要数据 只显示一次。
正如您在上面的屏幕截图中看到的,我不想要数据 显示两次。
答案 0 :(得分:2)
您已将表格组件放入详细信息区域。对数据集中的每个记录重复详细信息带。你有两条记录,所以你的表重复两次;如果你有更多的数据,你会得到更多的重复。
您可以完全摆脱表格组件,将表格中的每个columnHeader
元素放入<columnHeader>
个频段,将每个detailCell
元素放入<detail>
个频段。这样做应该保留表组件的行为而不重复它。有关此示例,请参阅http://community.jaspersoft.com/wiki/designing-report。
或者,您只需将表格组件移动到不会重复的不同频段(例如<summary>
)。
答案 1 :(得分:1)
将表格组件复制到摘要区域并删除详细信息区域。
如果要在表数据中重复值,请在Ireport中编辑表组件并选择文本字段,然后取消选中文本字段的“打印重复值”复选框属性。
XML CODE将是这样的: -
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="560916c9-e02a-40c9-a7af-a63d285b900a"
isPrintRepeatedValues="false" x="0" y="0" width="131" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{schooldetails_Phone}]]>
</textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
答案 2 :(得分:0)
如果表在“列表”组件中多次显示,请取消选中“详细信息溢出时打印”,然后尝试。它对我有用。