我一直在浏览JasperReports Api和StackOverflow,我发现我需要声明一个变量并传递子报告中的每个子报告的值,即使它们是相同的。
我正在重构和旧报告。在这种情况下,我每周有一个子报表,它们返回相同的值。因为我需要计算主要的总数。我有4个不同的时间来计算每个报告。所以我必须在主要的4 x 5/7变量。我正在寻找一种方法,只为它们提供1个返回变量名。
这可能吗?
这是计算行政离职时间的方式:
(我要将其更改为分钟参数并使用a计算 文本字段中的格式而不是此格式。并在变量中求和, 但这就是我预先重构的那些)
<band height="8">
<subreport>
<reportElement isPrintRepeatedValues="false" x="325" y="3" width="5" height="5" uuid="2200e4dc-97da-4be9-bd0d-8e1bb6f2a548"/>
<subreportParameter name="CarerId">
<subreportParameterExpression><![CDATA[$F{Employee_Id}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="DayCalculated">
<subreportParameterExpression><![CDATA[new java.util.Date($P{StartDate}.getTime() + 48*60*60*1000)]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<returnValue subreportVariable="Global_Time_in_Day" toVariable="Global_Time_in_Day_3"/>
<returnValue subreportVariable="Global_Time_Cero" toVariable="Global_Time_Cero_3"/>
<subreportExpression><![CDATA["administrativeLeaves_in_planning10.jrxml"]]></subreportExpression>
</subreport>
<subreport>
<reportElement isPrintRepeatedValues="false" x="0" y="3" width="5" height="5" uuid="f7c041f5-0fb7-4340-9004-abb40a40d72b"/>
<subreportParameter name="CarerId">
<subreportParameterExpression><![CDATA[$F{Employee_Id}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="DayCalculated">
<subreportParameterExpression><![CDATA[$P{StartDate}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<returnValue subreportVariable="Global_Time_in_Day" toVariable="Global_Time_in_Day_1"/>
<returnValue subreportVariable="Global_Time_Cero" toVariable="Global_Time_Cero_1"/>
<subreportExpression><![CDATA["administrativeLeaves_in_planning10.jrxml"]]></subreportExpression>
</subreport>
<subreport>
<reportElement isPrintRepeatedValues="false" x="487" y="3" width="5" height="5" uuid="7582ab3d-165b-4c20-b0ec-8049096a1287"/>
<subreportParameter name="CarerId">
<subreportParameterExpression><![CDATA[$F{Employee_Id}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="DayCalculated">
<subreportParameterExpression><![CDATA[new java.util.Date($P{StartDate}.getTime() + 72*60*60*1000)]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<returnValue subreportVariable="Global_Time_in_Day" toVariable="Global_Time_in_Day_4"/>
<returnValue subreportVariable="Global_Time_Cero" toVariable="Global_Time_Cero_4"/>
<subreportExpression><![CDATA["administrativeLeaves_in_planning10.jrxml"]]></subreportExpression>
</subreport>
<subreport>
<reportElement isPrintRepeatedValues="false" x="164" y="3" width="5" height="5" uuid="f61b9c11-cd2e-4d0b-be64-2964ee8d2aaf"/>
<subreportParameter name="CarerId">
<subreportParameterExpression><![CDATA[$F{Employee_Id}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="DayCalculated">
<subreportParameterExpression><![CDATA[new java.util.Date($P{StartDate}.getTime() + 24*60*60*1000)]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<returnValue subreportVariable="Global_Time_in_Day" toVariable="Global_Time_in_Day_2"/>
<returnValue subreportVariable="Global_Time_Cero" toVariable="Global_Time_Cero_2"/>
<subreportExpression><![CDATA["administrativeLeaves_in_planning10.jrxml"]]></subreportExpression>
</subreport>
<subreport>
<reportElement isPrintRepeatedValues="false" x="649" y="3" width="5" height="5" uuid="359cbbca-c469-4c35-9e44-68c286a953a9"/>
<subreportParameter name="CarerId">
<subreportParameterExpression><![CDATA[$F{Employee_Id}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="DayCalculated">
<subreportParameterExpression><![CDATA[new java.util.Date($P{StartDate}.getTime() + 96*60*60*1000)]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<returnValue subreportVariable="Global_Time_in_Day" toVariable="Global_Time_in_Day_5"/>
<returnValue subreportVariable="Global_Time_Cero" toVariable="Global_Time_Cero_5"/>
<subreportExpression><![CDATA["administrativeLeaves_in_planning10.jrxml"]]></subreportExpression>
</subreport>
</band>
然后全部添加(我知道这是我见过的最糟糕的代码之一):
(($V{Global_Time_in_Day_1} +
$V{Global_Time_in_Day_2} +
$V{Global_Time_in_Day_3} +
$V{Global_Time_in_Day_4} +
$V{Global_Time_in_Day_5} )%60) < 10
?
(($V{Global_Time_in_Day_1} +
$V{Global_Time_in_Day_2} +
$V{Global_Time_in_Day_3} +
$V{Global_Time_in_Day_4} +
$V{Global_Time_in_Day_5} )/60)
+":0"+
(($V{Global_Time_in_Day_1} +
$V{Global_Time_in_Day_2} +
$V{Global_Time_in_Day_3} +
$V{Global_Time_in_Day_4} +
$V{Global_Time_in_Day_5} )%60)+" h"
:
(($V{Global_Time_in_Day_1} +
$V{Global_Time_in_Day_2} +
$V{Global_Time_in_Day_3} +
$V{Global_Time_in_Day_4} +
$V{Global_Time_in_Day_5} )/60)
+":"+
(($V{Global_Time_in_Day_1} +
$V{Global_Time_in_Day_2} +
$V{Global_Time_in_Day_3} +
$V{Global_Time_in_Day_4} +
$V{Global_Time_in_Day_5} )%60)+" h"
我想要做的是<returnValue subreportVariable="Global_Time_in_Day" toVariable="Global_Time_in_Day"/>
到Main中的同一个变量并得到sumtory,而不是在main中每个子报告有一个Global_Time_in_Day_X
。
“书目”
http://jasperreports.sourceforge.net/sample.reference/subreport/index.html