4 Replies - 3530 Views - Last Post: 23 December 2011 - 12:10 AM Rate Topic: -----

#1 acll19  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 63
  • Joined: 20-October 10

jasper reports and table component issue

Posted 22 December 2011 - 10:54 PM

Hi, there. I´m designing a report with jasper reports that uses a table component to display the data. The thing is that when I see the preview it displays several tables on the same page and it creates several pages too, even though my query only returns 4 records, I have done a lot of search and found nothing. I would appreciate any help.
Is This A Good Question/Topic? 0
  • +

Replies To: jasper reports and table component issue

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10561
  • View blog
  • Posts: 39,072
  • Joined: 27-December 08

Re: jasper reports and table component issue

Posted 22 December 2011 - 11:23 PM

We don't really have enough information to help you. Please post your code using code tags in an effort for us to help you resolve your problems.
Was This Post Helpful? 0
  • +
  • -

#3 acll19  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 63
  • Joined: 20-October 10

Re: jasper reports and table component issue

Posted 22 December 2011 - 11:36 PM

Here´s my report xml:
<?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="porfactura" language="groovy" pageWidth="918" pageHeight="595" orientation="Landscape" columnWidth="878" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<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>
	</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>
	</style>
	<subDataset name="porfacturads">
		<parameter name="diap" class="java.lang.Integer">
			<defaultValueExpression><![CDATA[1]]></defaultValueExpression>
		</parameter>
		<parameter name="dia" class="java.lang.Integer">
			<defaultValueExpression><![CDATA[1]]></defaultValueExpression>
		</parameter>
		<parameter name="mes" class="java.lang.Integer">
			<defaultValueExpression><![CDATA[0]]></defaultValueExpression>
		</parameter>
		<parameter name="ano" class="java.lang.Integer">
			<defaultValueExpression><![CDATA[1988]]></defaultValueExpression>
		</parameter>
		<parameter name="tipo" class="java.lang.Integer">
			<defaultValueExpression><![CDATA[4]]></defaultValueExpression>
		</parameter>
		<queryString>
			<![CDATA[select u_medida, cantidad, id_prod, descripcion, saldo, dos_a, dos, cinco, p_unitario, dia, mes, anno, `compra_tb`.numero, nombre, ap_uno, ap_dos, carnet, importe   from compra_tb, productor_tb where `compra_tb`.id_prod = `productor_tb`.numero and (dia > $P{diap} or dia = $P{diap}) and (dia < $P{dia} or dia = $P{dia}) and mes = $P{mes} and anno = $P{ano};]]>
		</queryString>
		<field name="u_medida" class="java.lang.String"/>
		<field name="cantidad" class="java.lang.Double"/>
		<field name="id_prod" class="java.lang.Integer"/>
		<field name="descripcion" class="java.lang.String"/>
		<field name="saldo" class="java.lang.Double"/>
		<field name="dos_a" class="java.lang.Double"/>
		<field name="dos" class="java.lang.Double"/>
		<field name="cinco" class="java.lang.Double"/>
		<field name="p_unitario" class="java.lang.Double"/>
		<field name="dia" class="java.lang.Integer"/>
		<field name="mes" class="java.lang.Integer"/>
		<field name="anno" class="java.lang.Integer"/>
		<field name="numero" class="java.lang.Integer"/>
		<field name="nombre" class="java.lang.String"/>
		<field name="ap_uno" class="java.lang.String"/>
		<field name="ap_dos" class="java.lang.String"/>
		<field name="carnet" class="java.lang.String"/>
		<field name="importe" class="java.lang.Double"/>
		<group name="productor_tb_carnet">
			<groupExpression><![CDATA[$F{carnet}]]></groupExpression>
		</group>
	</subDataset>
	<queryString language="SQL">
		<![CDATA[select * from compra_tb, tipo_tb, productor_tb;]]>
	</queryString>
	<field name="numero" class="java.lang.Integer"/>
	<field name="nombre" class="java.lang.String"/>
	<field name="ap_uno" class="java.lang.String"/>
	<field name="ap_dos" class="java.lang.String"/>
	<field name="carnet" class="java.lang.String"/>
	<field name="descripcion" class="java.lang.String"/>
	<field name="cantidad" class="java.lang.Double"/>
	<field name="u_medida" class="java.lang.String"/>
	<field name="p_unitario" class="java.lang.Double"/>
	<field name="cinco" class="java.lang.Double"/>
	<field name="dos_a" class="java.lang.Double"/>
	<field name="dos" class="java.lang.Double"/>
	<field name="saldo" class="java.lang.Double"/>
	<field name="id_tipo" class="java.lang.Integer"/>
	<field name="id_prod" class="java.lang.Integer"/>
	<group name="carnet">
		<groupExpression><![CDATA[$F{carnet}]]></groupExpression>
	</group>
	<background>
		<band splitType="Stretch"/>
	</background>
	<pageHeader>
		<band height="35" splitType="Stretch">
			<staticText>
				<reportElement x="225" y="9" width="458" height="20"/>
				<textElement>
					<font size="13" isBold="true"/>
					<paragraph leftIndent="25"/>
				</textElement>
				<text><![CDATA[Control de Pago al Sector Cooperativo y Campesino. Sistema de Facturación]]></text>
			</staticText>
		</band>
	</pageHeader>
	<detail>
		<band height="163" splitType="Stretch">
			<componentElement>
				<reportElement key="table 1" style="table 1" x="0" y="0" width="878" height="163"/>
				<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="porfacturads">
						<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
					</datasetRun>
					<jr:column width="50">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="50" height="30"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<text><![CDATA[# de Factura]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="50" height="20"/>
								<textElement>
									<paragraph leftIndent="8"/>
								</textElement>
								<textFieldExpression class="java.lang.Integer"><![CDATA[$F{numero}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="90">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="90" height="30"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<text><![CDATA[Nombre(s)]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="90" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$F{nombre}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="90">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="90" height="30"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<text><![CDATA[Primer Apellido]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="90" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$F{ap_uno}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="90">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="90" height="30"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<text><![CDATA[Segundo Apellido]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="90" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$F{ap_dos}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="90">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="90" height="30"/>
								<textElement>
									<paragraph leftIndent="35"/>
								</textElement>
								<text><![CDATA[C/I]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="90" height="20"/>
								<textElement>
									<paragraph leftIndent="10"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$F{carnet}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="90">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="90" height="30"/>
								<textElement>
									<paragraph leftIndent="25"/>
								</textElement>
								<text><![CDATA[Producto]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="90" height="20"/>
								<textElement>
									<paragraph leftIndent="8"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$F{descripcion}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="52">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="50" height="30"/>
								<textElement>
									<paragraph leftIndent="4"/>
								</textElement>
								<text><![CDATA[Cantidad]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="50" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.Double"><![CDATA[$F{cantidad}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="37">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="34" height="30"/>
								<textElement>
									<paragraph leftIndent="8"/>
								</textElement>
								<text><![CDATA[U/M]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="34" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.String"><![CDATA[$F{u_medida}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="48">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="46" height="30"/>
								<textElement>
									<paragraph leftIndent="8"/>
								</textElement>
								<text><![CDATA[Precio]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="46" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.Double"><![CDATA[$F{p_unitario}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="49">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="46" height="30"/>
								<textElement>
									<paragraph leftIndent="6"/>
								</textElement>
								<text><![CDATA[Importe]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="46" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.Double"><![CDATA[$F{importe}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="48">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="46" height="30"/>
								<textElement>
									<paragraph leftIndent="9"/>
								</textElement>
								<text><![CDATA[Cinco]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="46" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.Double"><![CDATA[$F{cinco}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="48">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="46" height="30"/>
								<textElement>
									<paragraph leftIndent="13"/>
								</textElement>
								<text><![CDATA[Dos]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="46" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.Double"><![CDATA[$F{dos_a}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="48">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="46" height="30"/>
								<textElement>
									<paragraph leftIndent="13"/>
								</textElement>
								<text><![CDATA[Dos]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="46" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.Double"><![CDATA[$F{dos}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
					<jr:column width="47">
						<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
							<staticText>
								<reportElement x="0" y="0" width="46" height="30"/>
								<textElement>
									<paragraph leftIndent="10"/>
								</textElement>
								<text><![CDATA[Total]]></text>
							</staticText>
						</jr:columnHeader>
						<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
							<textField>
								<reportElement x="0" y="0" width="46" height="20"/>
								<textElement>
									<paragraph leftIndent="2"/>
								</textElement>
								<textFieldExpression class="java.lang.Double"><![CDATA[$F{saldo}]]></textFieldExpression>
							</textField>
						</jr:detailCell>
					</jr:column>
				</jr:table>
			</componentElement>
		</band>
	</detail>
</jasperReport>



and I use this method to load the report:
public static void ejecutarReporte(String reportFile, Map parametros) throws Exception{
         ConfManager mang = ConfManager.getInstance();
         conn = Connnexion.connect(mang);
         JasperReport masterReport= null;
         try {
            masterReport= (JasperReport) JRLoader.loadObject(reportFile);
         }
         catch (JRException e) {
            throw new Exception("Error cargando el reporte maestro: " + e.getMessage());
         }
        JasperPrint jasperPrint= JasperFillManager.fillReport(masterReport,parametros,conn);
        JasperViewer jViewer  = new JasperViewer(jasperPrint, false);
        jViewer.setFitPageZoomRatio();
        jViewer.setTitle("Listado de Productores");
        jViewer.setVisible(true);
    }


Was This Post Helpful? 0
  • +
  • -

#4 Ghlavac  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 519
  • Joined: 14-January 09

Re: jasper reports and table component issue

Posted 22 December 2011 - 11:41 PM

Wouldn't it be more pertinent to post your questions on the jasperreport forums?

http://jasperforge.o...rreports/forum/
Was This Post Helpful? 0
  • +
  • -

#5 acll19  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 63
  • Joined: 20-October 10

Re: jasper reports and table component issue

Posted 23 December 2011 - 12:10 AM

that would be a resource, but I´m telling you I´m finding really hard to find some information that could help me fix this problem. Thanks for the suggestion.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1