Jasper之table报表

这段时间用Jasper画报表,讲真的Jasper IDE真的很难用,网上找很久都没找到用table画的配置方法,以下是直接操作源码画table的方法,不用IDE一样可以做出来(不过样式还是得借助IDE拖拽调整容易些),以下是简要介绍,如果你对Jasper比较熟悉,只需得知table数据源的配置方式可以跳过前面的直接看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="CC_RESULT_INV" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5d4aa9eb-83ee-4f4d-a663-80ec6888dacb">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="iwmsinnerdataAdaptercount_result_inv.xml"/>(配置适配器)
<property name="net.sf.jasperreports.print.create.bookmarks" value="false"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<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>
</style>
<style name="Table_CH" 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>
</style>
<subDataset name="count_result_inv" uuid="86287dda-f4b9-4a82-ad21-41fe0aa75034">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="iwmsinnerdataAdaptercount_result_inv.xml"/>(数据源配置  以下的field是table里的参数
<field name="num" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="num"/>
<fieldDescription><![CDATA[num]]></fieldDescription>
</field>
<field name="ownerCode" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="ownerCode"/>
<fieldDescription><![CDATA[ownerCode]]></fieldDescription>
</field>
<field name="ownerName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="ownerName"/>
<fieldDescription><![CDATA[ownerName]]></fieldDescription>
</field>
<field name="barcode" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="barcode"/>
<fieldDescription><![CDATA[barcode]]></fieldDescription>
</field>
<field name="skuName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="skuName"/>
<fieldDescription><![CDATA[skuName]]></fieldDescription>
</field>
<field name="size" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="size"/>
<fieldDescription><![CDATA[size]]></fieldDescription>
</field>
<field name="color" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="color"/>
<fieldDescription><![CDATA[color]]></fieldDescription>
</field>
<field name="styleNum" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="styleNum"/>
<fieldDescription><![CDATA[styleNum]]></fieldDescription>
</field>
<field name="brand" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="brand"/>
<fieldDescription><![CDATA[brand]]></fieldDescription>
</field>
<field name="lot" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="lot"/>
<fieldDescription><![CDATA[lot]]></fieldDescription>
</field>
<field name="loc" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="loc"/>
<fieldDescription><![CDATA[loc]]></fieldDescription>
</field>
<field name="lpn" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="lpn"/>
<fieldDescription><![CDATA[lpn]]></fieldDescription>
</field>
<field name="caseNum" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="caseNum"/>
<fieldDescription><![CDATA[caseNum]]></fieldDescription>
</field>
<field name="systemQty" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="systemQty"/>
<fieldDescription><![CDATA[systemQty]]></fieldDescription>
</field>
<field name="qty" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="qty"/>
<fieldDescription><![CDATA[qty]]></fieldDescription>
</field>
<field name="diffQty" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="diffQty"/>
<fieldDescription><![CDATA[diffQty]]></fieldDescription>
</field>
<field name="countTime" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="countTime"/>
<fieldDescription><![CDATA[countTime]]></fieldDescription>
</field>
</subDataset>
<parameter name="tenantId" class="java.lang.Long">(parameter 是获取报表需要的参数)
<parameterDescription><![CDATA[租户ID]]></parameterDescription>
</parameter>
<parameter name="warehouseCode" class="java.lang.String">
<parameterDescription><![CDATA[仓库编码]]></parameterDescription>
</parameter>
<parameter name="countNum" class="java.lang.String">
<parameterDescription><![CDATA[盘点单号]]></parameterDescription>
</parameter>
<parameter name="operatorId" class="java.lang.Long">
<parameterDescription><![CDATA[制单人ID]]></parameterDescription>
</parameter>
<parameter name="operatorName" class="java.lang.String">
<parameterDescription><![CDATA[制单人名称]]></parameterDescription>
</parameter>
<queryString language="jsonql">
<![CDATA[po]]>
</queryString>(此处很关键 数据入口)
<field name="startCountTime" class="java.lang.String">(以下field是table外的数据配置)
<propertyExpression name="net.sf.jasperreports.jsonql.field.expression"><![CDATA["$.po.startCountTime"]]></propertyExpression>(根据自己的数据结构设置
<fieldDescription><![CDATA[startCountTime]]></fieldDescription>
</field>
<field name="endCountTime" class="java.lang.String">
<propertyExpression name="net.sf.jasperreports.jsonql.field.expression"><![CDATA["$.po.endCountTime"]]></propertyExpression>
<fieldDescription><![CDATA[endCountTime]]></fieldDescription>
</field>
<field name="countNum" class="java.lang.String">
<propertyExpression name="net.sf.jasperreports.jsonql.field.expression"><![CDATA["$.po.countNum"]]></propertyExpression>
<fieldDescription><![CDATA[countNum]]></fieldDescription>
</field>
<field name="printUser" class="java.lang.String">
<propertyExpression name="net.sf.jasperreports.jsonql.field.expression"><![CDATA["$.po.printUser"]]></propertyExpression>
<fieldDescription><![CDATA[printUser]]></fieldDescription>
</field>
<field name="printTime" class="java.lang.String">
<propertyExpression name="net.sf.jasperreports.jsonql.field.expression"><![CDATA["$.po.printTime"]]></propertyExpression>
<fieldDescription><![CDATA[printTime]]></fieldDescription>
</field>
<title>(以下是报表的title部分 table以外的数据
<band height="51" splitType="Stretch">
<staticText>
<reportElement x="300" y="5" width="120" height="46" uuid="31b1855e-439d-449f-9591-6e16996760db"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="28" isBold="true"/>
</textElement>
<text><![CDATA[盘点结果]]></text>
</staticText>
<componentElement>
<reportElement x="666" y="2" width="134" height="46" uuid="fea5b4d4-e6ec-42fd-82d5-59e4158cfd79">
<property name="com.jaspersoft.studio.unit.barHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.barWidth" value="pixel"/>
</reportElement>
<jr:barbecue xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" type="Code128" drawText="true" checksumRequired="false" barHeight="80">
<jr:codeExpression><![CDATA[$F{countNum}]]></jr:codeExpression>
</jr:barbecue>(条形码设置)
</componentElement>
<staticText>
<reportElement x="422" y="25" width="78" height="24" uuid="191f0487-b4e5-45c6-bf7d-d38196eae32c"/>
<textElement verticalAlignment="Bottom">
<font fontName="微软雅黑" size="14" isBold="true"/>
</textElement>
<text><![CDATA[按库存明细]]></text>
</staticText>
<staticText>
<reportElement x="10" y="10" width="70" height="20" uuid="b859a323-a943-49fa-b72c-7eb2a44ec43f">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[开始盘点时间:]]></text>
</staticText>
<textField isBlankWhenNull="true">
<reportElement x="80" y="10" width="60" height="20" uuid="ea625a37-da6a-4cfd-8504-703266ae40b8">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{startCountTime}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="30" width="70" height="20" uuid="b859a323-a943-49fa-b72c-7eb2a44ec43f">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[结束盘点时间:]]></text>
</staticText>
<textField isBlankWhenNull="true">
<reportElement x="80" y="31" width="60" height="20" uuid="ea625a37-da6a-4cfd-8504-703266ae40b8">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{endCountTime}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</band>
</pageHeader>
<detail>
<band height="100" splitType="Stretch">
<componentElement>
<reportElement x="0" y="4" width="800" height="96" uuid="744b22a9-27f5-4996-93c9-bc7f9747e36f">
<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>

以下是本文的关键 table 如果你对其他很熟悉只需看这里和上面的count_result_inv数据配置和数据的使用格式即可
<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="count_result_inv" uuid="9ea6754d-e599-4deb-8c74-80c26377ff02"> (table数据源设置 和之前设置的数据源相同)
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("details")]]></dataSourceExpression>(details便是table里需要的列表数据 对应你自己的参数名)
</datasetRun>

(以下是table里的结构 列名和对应的参数设置)
<jr:column width="40" uuid="7419436a-d528-4a26-acc9-8a5b5cd7ab97">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="0a953536-f431-4d02-984e-e4e63d99271c"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[序号]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="bf44b38f-9722-465c-911b-0e56358f4650"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{num}]]></textFieldExpression>(参数设置 对应数据源的参数名)
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="50" uuid="0cff022e-5c39-4b32-b6f6-c72d62173d3c">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="50" height="30" uuid="847baa13-0ab9-410d-bd7b-4dddb144e3cc"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[货主编码]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="50" height="30" uuid="cb40707d-9b0d-4969-bbd0-ae5ee281d3c0"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{ownerCode}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="54" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="54" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[货主名称]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="54" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{ownerName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="50" uuid="0cff022e-5c39-4b32-b6f6-c72d62173d3c">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="50" height="30" uuid="847baa13-0ab9-410d-bd7b-4dddb144e3cc"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[商品条码]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="50" height="30" uuid="cb40707d-9b0d-4969-bbd0-ae5ee281d3c0"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{barcode}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="56" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="56" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[商品名称]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="56" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{skuName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="40" uuid="0cff022e-5c39-4b32-b6f6-c72d62173d3c">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="847baa13-0ab9-410d-bd7b-4dddb144e3cc"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[款号]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="cb40707d-9b0d-4969-bbd0-ae5ee281d3c0"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{styleNum}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="36" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="36" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[颜色]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="36" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{color}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="40" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[尺码]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{size}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="40" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[品牌]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{brand}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="66" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="66" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[批次]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="66" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{lot}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="58" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="58" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[库位]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="58" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{loc}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="50" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="50" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[LPN]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="50" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{lpn}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="46" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="46" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[箱号]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="46" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{caseNum}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="40" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[库存量]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{systemQty}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="40" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[盘点量]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{qty}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="40" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[差异量]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{diffQty}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="56" uuid="ad2d764d-26cf-45b9-b95b-c981f56fbfe4">
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="56" height="30" uuid="4e6f71e0-54ba-4097-80eb-53427306f0b1"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[盘点时间]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="56" height="30" uuid="18533c81-f490-48db-a5cf-14d03eee6031"/>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{countTime}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</band>
</columnFooter>
<pageFooter>(以下也是table外数据设置)
<band height="93">
<staticText>
<reportElement x="10" y="0" width="53" height="20" uuid="5a81f2b8-edc5-42c0-9c06-4767a8ecb031">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[制 单 人 :]]></text>
</staticText>
<textField isBlankWhenNull="true">
<reportElement x="63" y="0" width="80" height="20" uuid="0c06794d-81f4-454c-b4cc-20d4f87ed2b4">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{printUser}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="150" y="0" width="53" height="20" uuid="5a81f2b8-edc5-42c0-9c06-4767a8ecb031">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<text><![CDATA[制 单时间:]]></text>
</staticText>
<textField isBlankWhenNull="true">
<reportElement x="203" y="0" width="147" height="20" uuid="0c06794d-81f4-454c-b4cc-20d4f87ed2b4">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Bottom">
<font fontName="微软雅黑" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{printTime}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</band>
</summary>
</jasperReport>

我的数据格式:

{
"po": {
"countNum": "123456789",
"startCountTime": "1000",
"endCountTime": "1000",
"printUser": "1000",
"printTime": "1000",
details:
[
{
"num": "1",
"ownerCode": "OW2913221",
"ownerName": "张三",
"barcode": "SKU201708250822",
"skuName":"好商品不要用选",
"size": "102",
"color": "红",
"styleNum": "25",
"brand": "1000",
"lot": "1000",
"loc": "1000",
"lpn": "1000",
"caseNum": "1",
"systemQty": "100",
"qty": "10",
"diffQty": "-90",
"countTime": "1000"
},
{
"num": "1",
"ownerCode": "OW2913221",
"ownerName": "张三",
"barcode": "SKU201708250822",
"skuName":"好商品不要用选",
"size": "102",
"color": "红",
"styleNum": "25",
"brand": "1000",
"lot": "1000",
"loc": "1000",
"lpn": "1000",
"caseNum": "1",
"systemQty": "100",
"qty": "10",
"diffQty": "-90",
"countTime": "1000"
}]
}
}

报表效果:

原文地址:https://www.cnblogs.com/AmbitiousMice/p/7793623.html