表格列的总数不适用于Jasper报告

时间:2017-09-25 05:25:50

标签: jasper-reports

您好我正在制作一个Jasper Report,其中我必须在Grand Total中显示Table列的总和。我试过但它不起作用。 这是源代码。

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1  -->
<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="FirstReport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="30c188b7-abdd-4ce1-ae90-3170e2ab71ee">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JavaDatabase"/>
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <style name="Table_TH" mode="Opaque" backcolor="#3F4040">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#3F4040">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
        <conditionalStyle>
            <conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
            <style backcolor="#DCE0E0"/>
        </conditionalStyle>
    </style>
    <subDataset name="Dataset1" uuid="cafe24a3-dba6-44ed-a0fb-c6666cd0485e">
        <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JavaDatabase"/>
        <queryString language="SQL">
            <![CDATA[select * from BillingCustomer]]>
        </queryString>
        <field name="In_Code" class="java.lang.Object"/>
        <field name="In_Date" class="java.lang.Object"/>
        <field name="C_Code" class="java.lang.Object"/>
        <field name="C_Name" class="java.lang.Object"/>
        <field name="C_Contact" class="java.lang.Object"/>
        <field name="Pay_Mode" class="java.lang.Object"/>
        <field name="Pay" class="java.lang.Object"/>
        <field name="Pay_Date" class="java.lang.Object"/>
        <field name="P_Code" class="java.lang.Object"/>
        <field name="P_Name" class="java.lang.Object"/>
        <field name="Price" class="java.lang.Object"/>
        <field name="Qnty" class="java.lang.Object"/>
        <field name="Amt" class="java.lang.Object"/>
        <field name="Dis_Per" class="java.lang.Object"/>
        <field name="Dis" class="java.lang.Object"/>
        <field name="Vat_Per" class="java.lang.Object"/>
        <field name="Vat" class="java.lang.Object"/>
        <field name="Tot_Amt" class="java.lang.Object"/>
        <field name="G_Tot" class="java.lang.Object"/>
        <field name="Tot_Pay" class="java.lang.Object"/>
        <field name="Pay_Due" class="java.lang.Object"/>
        <field name="Remark" class="java.lang.Object"/>
        <group name="In_Code">
            <groupExpression><![CDATA[$F{In_Code}]]></groupExpression>
        </group>
        <group name="In_Date">
            <groupExpression><![CDATA[$F{In_Date}]]></groupExpression>
        </group>
        <group name="C_Code">
            <groupExpression><![CDATA[$F{C_Code}]]></groupExpression>
        </group>
        <group name="C_Name">
            <groupExpression><![CDATA[$F{C_Name}]]></groupExpression>
        </group>
        <group name="C_Contact">
            <groupExpression><![CDATA[$F{C_Contact}]]></groupExpression>
        </group>
        <group name="Pay_Mode">
            <groupExpression><![CDATA[$F{Pay_Mode}]]></groupExpression>
        </group>
        <group name="Pay">
            <groupExpression><![CDATA[$F{Pay}]]></groupExpression>
        </group>
        <group name="Pay_Date">
            <groupExpression><![CDATA[$F{Pay_Date}]]></groupExpression>
        </group>
        <group name="P_Code">
            <groupExpression><![CDATA[$F{P_Code}]]></groupExpression>
        </group>
        <group name="P_Name">
            <groupExpression><![CDATA[$F{P_Name}]]></groupExpression>
        </group>
        <group name="Price">
            <groupExpression><![CDATA[$F{Price}]]></groupExpression>
        </group>
        <group name="Qnty">
            <groupExpression><![CDATA[$F{Qnty}]]></groupExpression>
        </group>
        <group name="Amt">
            <groupExpression><![CDATA[$F{Amt}]]></groupExpression>
        </group>
        <group name="Dis_Per">
            <groupExpression><![CDATA[$F{Dis_Per}]]></groupExpression>
        </group>
        <group name="Dis">
            <groupExpression><![CDATA[$F{Dis}]]></groupExpression>
        </group>
        <group name="Vat_Per">
            <groupExpression><![CDATA[$F{Vat_Per}]]></groupExpression>
        </group>
        <group name="Vat">
            <groupExpression><![CDATA[$F{Vat}]]></groupExpression>
        </group>
        <group name="Tot_Amt">
            <groupExpression><![CDATA[$F{Tot_Amt}]]></groupExpression>
        </group>
        <group name="G_Tot">
            <groupExpression><![CDATA[$F{G_Tot}]]></groupExpression>
        </group>
        <group name="Tot_Pay">
            <groupExpression><![CDATA[$F{Tot_Pay}]]></groupExpression>
        </group>
        <group name="Pay_Due">
            <groupExpression><![CDATA[$F{Pay_Due}]]></groupExpression>
        </group>
        <group name="Remark">
            <groupExpression><![CDATA[$F{Remark}]]></groupExpression>
        </group>
    </subDataset>
    <queryString>
        <![CDATA[select * from BillingCustomer]]>
    </queryString>
    <field name="In_Code" class="java.lang.Object"/>
    <field name="In_Date" class="java.lang.Object"/>
    <field name="C_Code" class="java.lang.Object"/>
    <field name="C_Name" class="java.lang.Object"/>
    <field name="C_Contact" class="java.lang.Object"/>
    <field name="Pay_Mode" class="java.lang.Object"/>
    <field name="Pay" class="java.lang.Object"/>
    <field name="Pay_Date" class="java.lang.Object"/>
    <field name="P_Code" class="java.lang.Object"/>
    <field name="P_Name" class="java.lang.Object"/>
    <field name="Price" class="java.lang.Object"/>
    <field name="Qnty" class="java.lang.Object"/>
    <field name="Amt" class="java.lang.Object"/>
    <field name="Dis_Per" class="java.lang.Object"/>
    <field name="Dis" class="java.lang.Object"/>
    <field name="Vat_Per" class="java.lang.Object"/>
    <field name="Vat" class="java.lang.Object"/>
    <field name="Tot_Amt" class="java.lang.Object"/>
    <field name="G_Tot" class="java.lang.Integer"/>
    <field name="Tot_Pay" class="java.lang.Integer"/>
    <field name="Pay_Due" class="java.lang.Object"/>
    <field name="Remark" class="java.lang.Object"/>
    <variable name="GrandTotal" class="java.lang.Integer" calculation="Sum">
        <variableExpression><![CDATA[$F{G_Tot}]]></variableExpression>
    </variable>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="117" splitType="Stretch">
            <rectangle>
                <reportElement x="1" y="0" width="553" height="117" backcolor="#209D77" uuid="42329aa1-8952-4315-b296-26cfa95ea987">
                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                </reportElement>
            </rectangle>
            <image scaleImage="FillFrame">
                <reportElement x="80" y="10" width="90" height="97" uuid="c98368ab-0778-4330-b7f2-1faaeda8edbc">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                </reportElement>
                <imageExpression><![CDATA["C:/Users/Azaz/workspace/InventorySystem/Images/index3.jpg"]]></imageExpression>
            </image>
            <staticText>
                <reportElement x="267" y="5" width="100" height="22" forecolor="#FFFFFF" uuid="fc4003a1-d460-4091-b0ef-2b3084266387">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[ABC Pvt. Ltd.]]></text>
            </staticText>
            <staticText>
                <reportElement x="211" y="26" width="220" height="22" forecolor="#FFFFFF" uuid="bebf4b42-9438-4ed6-86cf-0a8c91c146c1">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[356/3 Malviaya Nagar Near Khatushiyam]]></text>
            </staticText>
            <staticText>
                <reportElement x="211" y="46" width="220" height="22" forecolor="#FFFFFF" uuid="c61b1093-0ec2-4eb9-bd3b-ea16d708031e">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[Mandir Indore]]></text>
            </staticText>
            <staticText>
                <reportElement x="211" y="67" width="220" height="22" forecolor="#FFFFFF" uuid="5bdded3f-c4f4-4794-83fe-4387acfbf4b0">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[Contact No.=7030456328]]></text>
            </staticText>
            <staticText>
                <reportElement x="211" y="87" width="220" height="22" forecolor="#FFFFFF" uuid="2998fcf5-2141-440b-8379-e0199c7ab866">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[Email ID: mohammadazaz966@gmail.com]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="293" splitType="Stretch">
            <componentElement>
                <reportElement x="0" y="0" width="555" height="200" uuid="24613219-67f2-4eb9-89bc-8b9e2eec94de">
                    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                    <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
                    <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
                    <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
                </reportElement>
                <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="b728e7b3-47ab-4030-9480-0deb2ac2d011">
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="80" uuid="c5906514-8ea9-42dd-948e-29b3ac6a13ab">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="80" height="30" forecolor="#FFFFFF" uuid="beb67e5b-e7cb-440f-8b0a-c188cca3e793"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                                </textElement>
                                <text><![CDATA[Invoice Code]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="80" height="30" uuid="89e305a7-0eff-4c6c-b9b5-e4f977df0c57"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isItalic="true"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{In_Code}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90" uuid="98b9cdba-4d70-4268-bac4-7e3d903604fc">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30" forecolor="#FFFFFF" uuid="1e7ad1e7-d8b4-4165-a5ca-caf1e272fc1e"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                                </textElement>
                                <text><![CDATA[Invoice Date]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="30" uuid="ac4c273d-7f1b-4f05-9681-afeb84f8e10b"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isItalic="true"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{In_Date}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="100" uuid="8a18b400-a89a-49e8-b745-5ccef4c129ae">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="100" height="30" forecolor="#FFFFFF" uuid="13700483-f2ee-474f-a722-86457bb469b2"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                                </textElement>
                                <text><![CDATA[Customer Name]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="100" height="30" uuid="6601d195-2fb8-4148-94a7-17e6efb7eef3"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isItalic="true"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{C_Name}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90" uuid="dcd35646-bea4-4014-8acc-9607e258a4ce">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30" forecolor="#FFFFFF" uuid="f1e19438-cb86-4c06-843a-b1b5e2965012"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                                </textElement>
                                <text><![CDATA[Grand Total]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="30" uuid="0575c69b-a945-4f89-ac74-9c8e04ffa782"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isItalic="true"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{G_Tot}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="80" uuid="1de20dc8-b681-44df-b4a5-789c99213e46">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="80" height="30" forecolor="#FFFFFF" uuid="7502a163-ef5f-49f5-a83e-b8386ce90944"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                                </textElement>
                                <text><![CDATA[Total Pay]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="80" height="30" uuid="49ab096d-8429-4c20-9bae-1ef306b4ac38"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isItalic="true"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{Tot_Pay}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="115" uuid="7a4af97a-2f49-409d-b8b6-c519d23b4c5e">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="115" height="30" forecolor="#FFFFFF" uuid="6dcc3df1-3d6e-4d7c-aede-cf344527238d"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isBold="true" isItalic="true"/>
                                </textElement>
                                <text><![CDATA[Payment Due]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="115" height="30" uuid="6cc10df6-1d58-4909-9e2d-7a67283d2e41"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="Times New Roman" size="12" isItalic="true"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{Pay_Due}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
    <columnFooter>
        <band height="71" splitType="Stretch">
            <rectangle>
                <reportElement x="380" y="0" width="174" height="71" uuid="7af5713f-a164-4c28-a96d-dfe7055802df"/>
                <graphicElement>
                    <pen lineWidth="1.0" lineStyle="Solid"/>
                </graphicElement>
            </rectangle>
            <staticText>
                <reportElement x="381" y="2" width="79" height="22" uuid="f5f1d65a-ca67-4211-8fd3-e1e7fb3d24fa">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="11" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[    Grand Total :]]></text>
            </staticText>
            <staticText>
                <reportElement x="381" y="24" width="79" height="22" uuid="33b9c64d-e17c-4068-afff-87454990467a">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="11" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[    Total Paid :]]></text>
            </staticText>
            <staticText>
                <reportElement x="381" y="47" width="79" height="22" uuid="09e502df-d672-460e-b50b-b1359d6b93b6">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="11" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[    Balance :]]></text>
            </staticText>
            <textField>
                <reportElement x="460" y="2" width="94" height="30" uuid="4b67a8ca-ad17-45c9-b5ae-2cb6854ade7b"/>
                <textFieldExpression><![CDATA[$V{GrandTotal}]]></textFieldExpression>
            </textField>
        </band>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

0 个答案:

没有答案