レポートに呼び出された列があり、呼び出された列の値が のときにtotalhours
色を元に戻したいと思っています。そのために、次の詳細を含む条件付きスタイルを作成しました。yellow
outtime
null
<style name="TotalHoursBackColor" lineSpacing="Single">
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($F{Out_time}.equals( null ))]]> </conditionExpression>
<style mode="Opaque" backcolor="#FFFF33" lineSpacing="Single"/>
</conditionalStyle>
</style>
上記のコードは、次の出力を提供します
SlNo. エンピッド インタイム アウトタイム トータルアワーズ 1 100 9:00 13:00 4:00 2 101 9:10 ヌルイエロー 3 105 9:30 13:30 14:30 ヌル 4 103 9:30 18:30 9:00 5 107 9:40 13:40 8:00 14:40 18:40 6 108 10:00 ヌルイエロー 7 106 10:00 13:00 14:00 ヌル
しかし、次のように出力したい:
SlNo. エンピッド インタイム アウトタイム トータルアワーズ 1 100 9:00 13:00 4:00 2 101 9:10 ヌルイエロー 3 105 9:30 13:30 黄 14:30 ヌル 4 103 9:30 18:30 9:00 5 107 9:40 13:40 8:00 14:40 18:40 6 108 10:00 ヌルイエロー 7 106 10:00 13:00 イエロー 14:00 ヌル
jrxml ファイルを見つけてください:
<?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="HRIS Employee Time
Sheet" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555"
leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<style name="TotalHoursBackColor" lineSpacing="Single">
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($F{Out_time}.equals( null ))]]></conditionExpression>
<style mode="Opaque" backcolor="#FFFF33" lineSpacing="Single"/>
</conditionalStyle>
</style>
<parameter name="Date" class="java.sql.Timestamp">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select hr.EmployeeID,convert(char(5), tr.In_Time, 108) as In_time,
convert(char(5), tr.Out_Time, 108) as Out_time,
convert(varchar(5), sum(datediff(minute, trr.In_Time, isnull(trr.Out_Time, dateadd(hh, 18, DATEADD(dd, DATEDIFF(dd, 0, trr.In_Time), 0))))) / 60)
+ ':' +
convert(varchar(5),sum(datediff(minute, trr.In_Time, isnull(trr.Out_Time, dateadd(hh, 18, DATEADD(dd, DATEDIFF(dd, 0, trr.In_Time), 0))))) % 60)
as TotalHours,
hr.FirstName, hr.LastName, hr.EmployeeNo
from HR_EMPLOYEES hr
Left Join HR_EMPLOYEE_TIMESHEET tr
on (hr.EmployeeID=tr.EmployeeID)
Left Join HR_EMPLOYEE_TIMESHEET trr
on (hr.EmployeeID=trr.EmployeeID)
where (trr.In_Time BETWEEN $P{Date} AND DATEADD(DAY, 1, $P{Date})
and tr.In_Time BETWEEN $P{Date} AND DATEADD(DAY, 1, $P{Date}))
and hr.locationID=1
group by hr.EmployeeID, tr.In_Time, tr.Out_Time, hr.FirstName, hr.LastName,
hr.EmployeeNo, hr.JoiningDate
order by hr.JoiningDate ASC]]>
</queryString>
<field name="EmployeeID" class="java.lang.Integer"/>
<field name="In_time" class="java.lang.String"/>
<field name="Out_time" class="java.lang.String"/>
<field name="TotalHours" class="java.lang.String"/>
<field name="FirstName" class="java.lang.String"/>
<field name="LastName" class="java.lang.String"/>
<field name="EmployeeNo" class="java.lang.String"/>
<variable name="counter" class="java.lang.Integer" incrementType="Group" incrementGroup="EmployeeSerialNumber">
<variableExpression><![CDATA[($V{EmployeeSerialNumber_COUNT} == 1) ? $V{counter} + 1 : $V{counter}]]></variableExpression>
<initialValueExpression><![CDATA[0]]></initialValueExpression>
</variable>
<variable name="outtime_check" class="java.lang.Boolean" incrementType="Group" incrementGroup="EmployeeOutTime">
<variableExpression><![CDATA[($F{Out_time}.equals(null)&& $V{EmployeeSerialNumber_COUNT}==1)?$V{outtime_check}:$F{TotalHours}]]></variableExpression>
</variable>
<group name="EmployeeSerialNumber">
<groupExpression><![CDATA[$F{EmployeeNo}]]></groupExpression>
</group>
<group name="EmployeeOutTime">
<groupExpression><![CDATA[$F{Out_time}]]></groupExpression>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<image>
<reportElement x="466" y="19" width="89" height="32"/>
<imageExpression class="java.lang.String"><![CDATA["D:\\timesheet\\logo.png"]]></imageExpression>
</image>
</band>
</title>
<pageHeader>
<band height="38" splitType="Stretch">
<staticText>
<reportElement x="125" y="0" width="204" height="20"/>
<textElement textAlignment="Center" lineSpacing="Single">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Employee Time Sheet - Bangalore]]></text>
</staticText>
<textField pattern="dd MMMMM yyyy">
<reportElement x="455" y="-2" width="100" height="18"/>
<textElement lineSpacing="Single">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression class="java.sql.Timestamp"><![CDATA[$P{Date}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="31" splitType="Stretch">
<staticText>
<reportElement x="155" y="7" width="100" height="20"/>
<textElement textAlignment="Center" lineSpacing="Single">
<font isBold="true"/>
</textElement>
<text><![CDATA[Name]]></text>
</staticText>
<staticText>
<reportElement x="293" y="7" width="86" height="20"/>
<textElement textAlignment="Center" lineSpacing="Single">
<font isBold="true"/>
</textElement>
<text><![CDATA[In Time]]></text>
</staticText>
<staticText>
<reportElement x="385" y="7" width="76" height="20"/>
<textElement textAlignment="Center" lineSpacing="Single">
<font isBold="true"/>
</textElement>
<text><![CDATA[Out Time]]></text>
</staticText>
<staticText>
<reportElement x="474" y="7" width="59" height="20"/>
<textElement textAlignment="Left" lineSpacing="Single">
<font isBold="true"/>
</textElement>
<text><![CDATA[Total Hours ]]></text>
</staticText>
<line>
<reportElement x="54" y="1" width="1" height="29"/>
</line>
<line>
<reportElement x="466" y="2" width="1" height="29"/>
</line>
<line>
<reportElement x="14" y="1" width="527" height="1"/>
</line>
<line>
<reportElement x="289" y="1" width="1" height="29"/>
</line>
<line>
<reportElement x="380" y="2" width="1" height="28"/>
</line>
<staticText>
<reportElement x="57" y="7" width="67" height="20"/>
<textElement textAlignment="Center" lineSpacing="Single">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Employee No.]]></text>
</staticText>
<line>
<reportElement x="128" y="2" width="1" height="28"/>
</line>
<line>
<reportElement x="430" y="30" width="111" height="1"/>
</line>
<staticText>
<reportElement x="20" y="7" width="30" height="20"/>
<textElement textAlignment="Center" lineSpacing="Single">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Sl No.]]></text>
</staticText>
<line>
<reportElement x="14" y="2" width="1" height="29"/>
</line>
</band>
</columnHeader>
<detail>
<band height="22" splitType="Stretch">
<line>
<reportElement x="54" y="0" width="1" height="22"/>
</line>
<line>
<reportElement x="466" y="0" width="1" height="22"/>
</line>
<line>
<reportElement x="13" y="-1" width="416" height="1"/>
</line>
<line>
<reportElement x="14" y="21" width="415" height="1"/>
</line>
<line>
<reportElement x="541" y="-29" width="1" height="50"/>
</line>
<line>
<reportElement x="289" y="0" width="1" height="21"/>
</line>
<line>
<reportElement x="380" y="-1" width="1" height="22"/>
</line>
<textField>
<reportElement isPrintRepeatedValues="false" x="68" y="1" width="44" height="20"/>
<textElement textAlignment="Center" lineSpacing="Single">
<font isBold="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{EmployeeNo}]]></textFieldExpression>
</textField>
<textField>
<reportElement isPrintRepeatedValues="false" x="134" y="1" width="148" height="20"/>
<textElement textAlignment="Left" lineSpacing="Single"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{FirstName} + " " + $F{LastName}]]></textFieldExpression>
</textField>
<line>
<reportElement x="128" y="0" width="1" height="22"/>
</line>
<line>
<reportElement x="430" y="21" width="111" height="1"/>
</line>
<textField>
<reportElement x="293" y="1" width="76" height="20"/>
<textElement textAlignment="Center" lineSpacing="Single"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{In_time}]]></textFieldExpression>
</textField>
<textField pattern="" isBlankWhenNull="true">
<reportElement mode="Transparent" x="384" y="1" width="76" height="20"/>
<textElement textAlignment="Center" lineSpacing="Single"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{Out_time}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="TotalHoursBackColor" isPrintRepeatedValues="false" x="477" y="1" width="62" height="20"/>
<textElement textAlignment="Left" lineSpacing="Single"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{TotalHours}]]></textFieldExpression>
</textField>
<line>
<reportElement x="14" y="1" width="1" height="20"/>
</line>
<textField>
<reportElement isPrintRepeatedValues="false" x="24" y="2" width="25" height="19">
<printWhenExpression><![CDATA[$V{EmployeeSerialNumber_COUNT}==1]]></printWhenExpression>
</reportElement>
<textElement lineSpacing="Single"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{counter}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch">
<textField>
<reportElement x="435" y="34" width="80" height="20"/>
<textElement textAlignment="Right" lineSpacing="Single"/>
<textFieldExpression class="java.lang.String"><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="515" y="34" width="40" height="20"/>
<textElement lineSpacing="Single"/>
<textFieldExpression class="java.lang.String"><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="41" splitType="Stretch"/>
</summary>
</jasperReport>
誰かがそれを取得する方法を教えてください