2013-11-20 66 views
0

對不起,打開這個問題。我想有人告訴我如何歸檔這個,因爲AI有同樣的問題,但我沒有得到預期的結果或this問題推測其可能,但我沒有得到一樣。JasperReports動態分組

我將與我的工作

<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="detailVisitShop" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" scriptletClass="net.sf.jasperreports.engine.JRDefaultScriptlet" uuid="4c82ee8a-2708-4b04-a1f3-b213d6c4c380"> 
    <property name="ireport.zoom" value="1.0"/> 
    <property name="ireport.x" value="0"/> 
    <property name="ireport.y" value="0"/> 
    <style name="Title" fontName="Times New Roman" fontSize="50" isBold="true" pdfFontName="Times-Bold"/> 
    <style name="SubTitle" forecolor="#736343" fontName="Arial" fontSize="18"/> 
    <style name="Column header" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/> 
    <style name="Detail" fontName="Arial" fontSize="16"/> 
    <style name="Row" mode="Transparent"> 
     <conditionalStyle> 
      <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression> 
      <style backcolor="#E6DAC3"/> 
     </conditionalStyle> 
    </style> 
    <parameter name="idCliente" class="java.lang.Integer"> 
     <defaultValueExpression><![CDATA[3]]></defaultValueExpression> 
    </parameter> 
    <parameter name="grpHeader" class="java.lang.String"> 
     <defaultValueExpression><![CDATA[]]></defaultValueExpression> 
    </parameter> 
    <queryString> 
     <![CDATA[SELECT 
    Cv.condicionventaname 'CondicionVenta', 
    concat(Cl.`names`, ' ', Cl.lastnames) 'Cliente', 
    U.userName 'Operador', 
    V.fecha, 
    V.Total,V.idventa,v.cliente_idcliente, 
    case 
     when Cv.idcondicionventa = 1 then concat('Folio ', cast(V.folio as char)) 
     else concat('Factura ', cast(V.factura as char)) 
    end as 'Numero de operacion', 
    case 
     when V.cars_numberplate is not null then concat('Placas ' , V.cars_numberplate) 
     when V.climas_idclimas is not null then concat('Numero de serie ', V.climas_idclimas) 
    end as 'Servicio A', V.cars_numberplate placas,V.climas_idclimas clima,U.userName 
from 
    Ventas V 
     left join 
    Climas cli ON Cli.idclimas = V.climas_idclimas 
     left join 
    Cars ca ON Ca.numberplate = V.cars_numberplate 
     left join 
    condicionventa Cv ON Cv.idcondicionventa = V.condicionventa_idcondicionventa 
     inner join 
    cliente Cl ON Cl.idcliente = V.cliente_idcliente 
     inner join 
    users U ON U.iduser = V.Users_idUser 
order by $P{grpHeader}]]> 
    </queryString> 
    <field name="CondicionVenta" class="java.lang.String"/> 
    <field name="Cliente" class="java.lang.String"/> 
    <field name="Operador" class="java.lang.String"/> 
    <field name="fecha" class="java.sql.Timestamp"/> 
    <field name="Total" class="java.lang.Double"/> 
    <field name="idventa" class="java.lang.Integer"/> 
    <field name="cliente_idcliente" class="java.lang.Integer"/> 
    <field name="Numero de operacion" class="java.lang.String"/> 
    <field name="Servicio A" class="java.lang.String"/> 
    <field name="placas" class="java.lang.String"/> 
    <field name="clima" class="java.lang.String"/> 
    <field name="userName" class="java.lang.String"/> 
    <variable name="variable1" class="java.lang.Double" resetType="Group" resetGroup="Group1" calculation="Sum"> 
     <variableExpression><![CDATA[$F{Total}]]></variableExpression> 
    </variable> 
    <variable name="groupVal" class="java.lang.Object"> 
     <variableExpression><![CDATA[$P{grpHeader}.equals("Placas") ? 
      $F{placas} : ($P{grpHeader}.equals("cliente") ? $F{Cliente} : $F{Cliente})]]></variableExpression> 
    </variable> 
    <variable name="numberOfVisits" class="java.lang.Integer" resetType="Group" resetGroup="Group1" calculation="Count"> 
     <variableExpression><![CDATA[$F{idventa}]]></variableExpression> 
    </variable> 
    <group name="Group1"> 
     <groupExpression><![CDATA[$P{grpHeader}]]></groupExpression> 
     <groupHeader> 
      <band height="37"> 
       <frame> 
        <reportElement uuid="b6aeacfd-18df-4b4e-8d03-b205cd4e0509" mode="Opaque" x="-21" y="7" width="843" height="24" forecolor="#B89F7D" backcolor="#F2EBDF"/> 
        <textField> 
         <reportElement uuid="87ff53e3-0507-4a1a-983d-c25f21767513" style="SubTitle" x="68" y="0" width="755" height="24" forecolor="#736343"/> 
         <textElement> 
          <font isBold="true"/> 
         </textElement> 
         <textFieldExpression><![CDATA[$F{placas}]]></textFieldExpression> 
        </textField> 
       </frame> 
      </band> 
     </groupHeader> 
     <groupFooter> 
      <band height="26"> 
       <rectangle> 
        <reportElement uuid="0a5f2335-ad9e-4a8c-8b77-0a2f5ffcfb2d" mode="Opaque" x="-1" y="0" width="802" height="25" forecolor="#FFFFFF" backcolor="#838E8E"/> 
       </rectangle> 
       <textField pattern="¤ #,##0.00" isBlankWhenNull="true"> 
        <reportElement uuid="7fb963f9-825a-498f-9635-98614f1f0893" x="559" y="5" width="202" height="20" forecolor="#FFCC00"/> 
        <textElement> 
         <font size="14"/> 
        </textElement> 
        <textFieldExpression><![CDATA[$V{variable1}]]></textFieldExpression> 
       </textField> 
       <textField pattern="¤ #,##0.00" isBlankWhenNull="true"> 
        <reportElement uuid="19e30ce4-bcd7-4763-87c8-20f95a64461a" x="459" y="0" width="100" height="25"/> 
        <textElement textAlignment="Center" verticalAlignment="Bottom"> 
         <font size="16"/> 
        </textElement> 
        <textFieldExpression><![CDATA["Total"]]></textFieldExpression> 
       </textField> 
       <textField pattern="¤ #,##0.00" isBlankWhenNull="true"> 
        <reportElement uuid="06e8276f-7143-4c0e-ad9f-336fabbead33" x="1" y="0" width="171" height="25"/> 
        <textElement verticalAlignment="Middle"> 
         <font size="16"/> 
        </textElement> 
        <textFieldExpression><![CDATA["Numero de vistas"]]></textFieldExpression> 
       </textField> 
       <textField pattern="" isBlankWhenNull="true"> 
        <reportElement uuid="e22bb9e4-770e-45cf-b4eb-30d7a0c50633" x="195" y="6" width="202" height="20"/> 
        <textElement> 
         <font size="14"/> 
        </textElement> 
        <textFieldExpression><![CDATA[$V{numberOfVisits}]]></textFieldExpression> 
       </textField> 
      </band> 
     </groupFooter> 
    </group> 

還我檢查其他來源,如this繼續,但我不能完成我的目標。所以這是不可能的,或者我做錯了?

回答

0

如果您want't改變SQL語句的參數,語法參數是一個有點不同。 在您例如,通過部分改變爲了這個:

order by $P!{grpHeader} 

沒有「!」之後$ P碧玉將插入格式化的值,所以在運行時,你會得到類似

order by "cliente" 

,而不是

order by cliente 

集團通過表達式看起來OK,你什麼時候運行報告你得到任何錯誤(在按條款排序後)?

+0

先生,我拿不出組,我做出了改變,我相信我不能讓它分辯以任何方式我離開它,就像這一點,並試圖動態報告 – GoAntonio

+0

非常感謝你:d – GoAntonio