Como alimentando uma variavel no Jasperreport?

2 respostas
java
A

Boa noite,

Estou finalizando um relatorio, e gostaria de setar ou alimentar uma variável no ireport + java, eu não sou muito expert em Ireport e gostaria da ajuda de vocês.

Lembrando que eu já consigo alimentar o relatório com os dados que preciso, no momento preciso especificar o tipo, e não sei se é por meio das variaveis que eu faço isso, mas conto com a ajuda de vocês;

Desde de já agradeço

2 Respostas

jacoboliveira

Dá um print na tela do ireport com o relatorio e mostra o teu xml

A

Segue imagem e Código.

<?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="null" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e7115a43-0608-4b7c-b4a5-750fc2df64d5">
	<property name="ireport.zoom" value="1.5"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<queryString>
		<![CDATA[Select count(d.descr) AS QTD, d.descr AS Descricao from fc12100 a, fc12110 b, fc03000 d, fc99999 e where a.nrcrm in
(Select nrcrm from fc04300 where cdesp = 005 and itemid = 1)
and a.cdfil = b.cdfil
and a.nrrqu = b.nrrqu
and b.tpcmp = 'C'
and b.cdprin=d.cdpro
and a.dtentr between '01.06.2016' and '01.06.2016' group by 2 order by 1 desc]]>
	</queryString>
	<field name="QTD" class="java.lang.Integer"/>
	<field name="DESCRICAO" class="java.lang.String"/>
	<variable name="Especialidade" class="java.lang.String"/>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="53" splitType="Stretch">
			<rectangle>
				<reportElement x="0" y="0" width="555" height="53" backcolor="#CCCCCC" uuid="9b902644-a783-4ab2-a6a6-737ffd4f9080"/>
			</rectangle>
			<staticText>
				<reportElement x="163" y="10" width="223" height="33" uuid="a719b9a1-ca06-445b-a392-cce406ab4d20"/>
				<textElement>
					<font size="24"/>
				</textElement>
				<text><![CDATA[Relatório Gerenciais]]></text>
			</staticText>
			<textField pattern="EEEEE dd MMMMM yyyy">
				<reportElement x="405" y="0" width="150" height="20" uuid="cad42d1a-cc65-4b6e-9866-4bb723aa8e5a"/>
				<textElement verticalAlignment="Middle">
					<font fontName="Arial" size="8"/>
				</textElement>
				<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band height="24" splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band height="26" splitType="Stretch">
			<staticText>
				<reportElement x="328" y="3" width="100" height="19" uuid="127a064b-15c1-4bff-a648-a953386680c4"/>
				<textElement textAlignment="Left" verticalAlignment="Middle">
					<font fontName="Arial" size="12" isBold="true"/>
				</textElement>
				<text><![CDATA[QTD]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Transparent" x="31" y="3" width="248" height="19" uuid="5cf83120-982c-45a0-8319-232bde93fee7"/>
				<textElement verticalAlignment="Middle">
					<font fontName="Arial" size="12" isBold="true"/>
				</textElement>
				<text><![CDATA[DESCRICAO]]></text>
			</staticText>
			<line>
				<reportElement mode="Opaque" x="0" y="21" width="555" height="1" uuid="53dac333-0c74-4b88-b3af-5456620abc24"/>
				<graphicElement>
					<pen lineStyle="Dashed"/>
				</graphicElement>
			</line>
			<line>
				<reportElement x="0" y="2" width="555" height="1" uuid="49fb3ba1-c8b4-4a56-b695-7a3a445cb0ae"/>
				<graphicElement>
					<pen lineWidth="2.0" lineStyle="Double"/>
				</graphicElement>
			</line>
		</band>
	</columnHeader>
	<detail>
		<band height="22" splitType="Stretch">
			<textField>
				<reportElement x="339" y="0" width="100" height="20" uuid="3a2161df-5914-43fe-b85f-02544ca0260a"/>
				<textElement verticalAlignment="Middle">
					<font fontName="Arial" size="8"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{QTD}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="44" y="0" width="267" height="20" backcolor="#FFFFFF" uuid="91c5ff36-e4e5-45fd-b60f-de6cca19c285"/>
				<textElement verticalAlignment="Middle">
					<font fontName="Arial" size="9"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{DESCRICAO}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band height="45" splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band height="54" splitType="Stretch">
			<textField>
				<reportElement x="455" y="34" width="100" height="20" uuid="a50fd9dc-7857-41df-8b1e-c4b755790822"/>
				<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
	<summary>
		<band height="42" splitType="Stretch"/>
	</summary>
</jasperReport>
Criado 28 de julho de 2016
Ultima resposta 29 de jul. de 2016
Respostas 2
Participantes 2