fasts
Fevereiro 27, 2012, 1:00pm
#1
Boa tarde!
Estou com um relatório aqui (http://www.guj.com.br/java/256136-tree-no-ireport-resolvido ) e agora preciso fazer o seguinte:
Colocar um “índice” com cada um dos separadores (Despesas de Escritório, Despesas com Pessoal etc.) antes da listagem e do cabeçalho.
Ele está assim:
http://img24.imageshack.us/img24/8742/relatoriow.png
Porém esses “títulos” ou “separadores” não vem do banco. A cada vez que o grupo muda ele checa e muda seu título.
Como eu faria isso na parte de cima? Já tentei deixar como está, apenas jogando pra cima e mudando algumas configs, mas ele só mostra uma vez o primeiro tipo.
Valeu!
Tem como postar o .jrxml?
fasts
Fevereiro 27, 2012, 1:31pm
#3
Claro!
<?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="financeiroDetalhado" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" 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"/>
<parameter name="receitas" class="java.math.BigDecimal"/>
<parameter name="despesas" class="java.math.BigDecimal"/>
<parameter name="resultado" class="java.math.BigDecimal"/>
<parameter name="nomeObra" class="java.lang.String"/>
<parameter name="porcDesp" class="java.math.BigDecimal"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="numero" class="java.lang.String">
<fieldDescription><![CDATA[codigo.numero]]></fieldDescription>
</field>
<field name="descricao" class="java.lang.String">
<fieldDescription><![CDATA[codigo.descricao]]></fieldDescription>
</field>
<field name="total" class="java.math.BigDecimal">
<fieldDescription><![CDATA[total]]></fieldDescription>
</field>
<variable name="porcDesp" class="java.math.BigDecimal">
<variableExpression><![CDATA[( $P{receitas}.compareTo(BigDecimal.ZERO) == 0 ? null : $P{despesas}.divide( $P{receitas}, MathContext.DECIMAL32 ) )]]></variableExpression>
</variable>
<variable name="porcResult" class="java.math.BigDecimal">
<variableExpression><![CDATA[( $P{receitas}.compareTo( BigDecimal.ZERO ) == 0 ? null : $P{resultado}.divide( $P{receitas}, MathContext.DECIMAL32 ) )]]></variableExpression>
</variable>
<variable name="porcCodigo" class="java.math.BigDecimal">
<variableExpression><![CDATA[( $F{numero}.charAt(0) == 4 ? $F{total}.divide($P{receitas}, MathContext.DECIMAL32) : $F{total}.divide($P{despesas}, MathContext.DECIMAL32) )]]></variableExpression>
</variable>
<variable name="fixasVariaveis" class="java.lang.String" resetType="Group" resetGroup="fixas">
<variableExpression><![CDATA[( $F{numero}.startsWith( "31" ) ? "31 - Fixas" : "32 - Variáveis" )]]></variableExpression>
<initialValueExpression><![CDATA[( $F{numero}.startsWith( "31" ) ? "Fixas" : "Variáveis" )]]></initialValueExpression>
</variable>
<variable name="subFixasVariaveis" class="java.lang.String" resetType="Group" resetGroup="subFixas">
<variableExpression><![CDATA[( $F{numero}.startsWith( "311" ) ? "Despesas de Escritório" :
( $F{numero}.startsWith( "312" ) ? "Despesas com Pessoal Administrativo" :
( $F{numero}.startsWith( "321" ) ? "Material" :
( $F{numero}.startsWith( "322" ) ? "Ferramentas e Equipamentos" :
( $F{numero}.startsWith( "323" ) ? "Mão de Obra" :
( $F{numero}.startsWith( "324" ) ? "Serviços de Terceiros" :
( $F{numero}.startsWith( "325" ) ? "Operacionais" :
( $F{numero}.startsWith( "326" ) ? "Comerciais" :
( $F{numero}.startsWith( "327" ) ? "Impostos" :
( $F{numero}.startsWith( "328" ) ? "Despesas Financeiras" :
( $F{numero}.startsWith( "329" ) ? "Dividendos e retiradas" : null )))))))))))]]></variableExpression>
<initialValueExpression><![CDATA[( $F{numero}.startsWith( "311" ) ? "Despesas de Escritório" :
( $F{numero}.startsWith( "312" ) ? "Despesas com Pessoal Administrativo" :
( $F{numero}.startsWith( "321" ) ? "Material" :
( $F{numero}.startsWith( "322" ) ? "Ferramentas e Equipamentos" :
( $F{numero}.startsWith( "323" ) ? "Mão de Obra" : null ) ) ) ) )]]></initialValueExpression>
</variable>
<variable name="somaTipos" class="java.math.BigDecimal" resetType="Group" resetGroup="subFixas" calculation="Sum">
<variableExpression><![CDATA[$F{total}]]></variableExpression>
<initialValueExpression><![CDATA[]]></initialValueExpression>
</variable>
<variable name="porcSubFixas" class="java.math.BigDecimal">
<variableExpression><![CDATA[$V{somaTipos}.divide( $P{despesas}, MathContext.DECIMAL128 )]]></variableExpression>
</variable>
<group name="fixas">
<groupExpression><![CDATA[$F{numero}.startsWith( "31" )]]></groupExpression>
<groupHeader>
<band height="20">
<textField>
<reportElement isPrintRepeatedValues="false" x="77" y="0" width="168" height="20"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{fixasVariaveis}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</group>
<group name="subFixas">
<groupExpression><![CDATA[$F{numero}.substring( 0, 3 )]]></groupExpression>
<groupHeader>
<band height="20">
<textField evaluationTime="Group" evaluationGroup="subFixas">
<reportElement x="77" y="0" width="168" height="20"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{subFixasVariaveis}]]></textFieldExpression>
</textField>
<textField evaluationTime="Group" evaluationGroup="subFixas" pattern="#,##0.00">
<reportElement x="412" y="0" width="92" height="20"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{somaTipos}]]></textFieldExpression>
</textField>
<textField evaluationTime="Group" evaluationGroup="subFixas" pattern="#,##0.00 %" isBlankWhenNull="true">
<reportElement x="514" y="0" width="41" height="20"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{porcSubFixas}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</group>
<background>
<band splitType="Prevent"/>
</background>
<title>
<band height="113" splitType="Prevent">
<rectangle radius="10">
<reportElement key="rectangle" mode="Transparent" x="0" y="0" width="554" height="20"/>
</rectangle>
<staticText>
<reportElement key="staticText" x="168" y="0" width="226" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Relatório Financeiro Analítico]]></text>
</staticText>
<textField pattern="dd/MM/yyyy" isBlankWhenNull="false">
<reportElement key="textField" x="493" y="0" width="51" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="10"/>
</textElement>
<textFieldExpression><![CDATA[new Date()]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="437" y="0" width="56" height="20"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Emitido em]]></text>
</staticText>
<staticText>
<reportElement x="0" y="54" width="51" height="19"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Receitas]]></text>
</staticText>
<staticText>
<reportElement x="0" y="73" width="51" height="20"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Despesas]]></text>
</staticText>
<staticText>
<reportElement x="0" y="93" width="51" height="20"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Resultado]]></text>
</staticText>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement isPrintRepeatedValues="false" x="51" y="54" width="67" height="19"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{receitas}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement isPrintRepeatedValues="false" x="51" y="73" width="67" height="20"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{despesas}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement isPrintRepeatedValues="false" x="51" y="93" width="67" height="20"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{resultado}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="30" width="555" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Obra: " + $P{nomeObra}]]></textFieldExpression>
</textField>
<textField evaluationTime="Auto" pattern="#,##0.00 %" isBlankWhenNull="true">
<reportElement isPrintRepeatedValues="false" x="128" y="93" width="40" height="20"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{porcResult}]]></textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
<band height="20" splitType="Prevent">
<rectangle>
<reportElement mode="Opaque" x="0" y="0" width="555" height="20" backcolor="#CCCCCC"/>
<graphicElement>
<pen lineWidth="0.0"/>
</graphicElement>
</rectangle>
<staticText>
<reportElement x="0" y="0" width="77" height="20"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Código]]></text>
</staticText>
<staticText>
<reportElement x="77" y="0" width="334" height="20"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Descrição]]></text>
</staticText>
<staticText>
<reportElement x="436" y="0" width="79" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[R$]]></text>
</staticText>
<staticText>
<reportElement x="525" y="0" width="30" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[%]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Prevent">
<elementGroup>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement x="0" y="0" width="78" height="20" isRemoveLineWhenBlank="true"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{numero}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement x="448" y="0" width="56" height="20" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{total}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00 %" isBlankWhenNull="true">
<reportElement x="514" y="0" width="40" height="20" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{porcCodigo}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement x="78" y="0" width="334" height="20" isRemoveLineWhenBlank="true"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{descricao}]]></textFieldExpression>
</textField>
</elementGroup>
</band>
</detail>
<pageFooter>
<band height="20" splitType="Prevent">
<staticText>
<reportElement key="staticText" x="157" y="0" width="253" height="20"/>
<textElement textAlignment="Justified" verticalAlignment="Middle">
<font fontName="SansSerif" size="11" isBold="false"/>
</textElement>
<text><![CDATA[]]></text>
</staticText>
</band>
</pageFooter>
</jasperReport>