Change Text Color based on string value

Hi All-

I want to change the color of the text to red on a text field if "OT" is found on the string.

Ex. This is the column, I want the line "OT(12:02 PM - 4:05 PM)" to change to red

Wednesday

12:00 PM - 4:00 PM
OT(12:02 PM - 4:05 PM)
8:00 PM - 10:00 PM

I am using XML as the datasource.  Here is an example of my xml file.

<?xml version="1.0" encoding="UTF-8"?>
<EmpSchedule>
    <Employee>
        <Name>Andrew Curren</Name>
        <Sun/>
        <Mon/>
        <Tue/>
        <Wed>12:00 PM - 4:00 PM
OT(12:02 PM - 4:05 PM)
8:00 PM - 10:00 PM
(8:02 PM - 10:02 PM)</Wed>
        <Thu/>
        <Fri/>
        <Sat/>
    </Employee>
</EmpSchedule>

So far, what I've done is I created a "Styles" and called "OT_Style"

Opaque = Checked
Forecolor = Red [255,0,0]
Backcolor = null
Bold = Checked

Then, I added the "Conditional Style"

$F{Wed}.contains( "OT" )

Then, on the text field, I selected "OT_Style" on the Style

The line with "OT[Time]" is not changing to Red, is it possilbe to do this? What am I doing wrong? Any help is greatly appreciated.

Thank you,

Alfie

alfie1109's picture
419
Joined: Jul 23 2018 - 11:13am
Last seen: 4 years 10 months ago

My issue right now is, it's changing ALL the text color of the field.  I think it's because it's treating the node as one string (which is true).  Not sure how to accomplish this now.......

 

<?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="EmployeeSummary" pageWidth="792" pageHeight="612" columnWidth="752" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="aa9f89d5-76da-42e6-9387-5eed0e9a269e">
    <property name="ireport.scriptlethandling" value="0"/>
    <property name="ireport.encoding" value="UTF-8"/>
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <import value="net.sf.jasperreports.engine.*"/>
    <import value="java.util.*"/>
    <import value="net.sf.jasperreports.engine.data.*"/>
    <style name="Arial_Normal" fontName="Arial" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
    <style name="Areal_Bold" mode="Opaque" fontName="Arial" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
    <style name="OT_Style" mode="Opaque" forecolor="#FF0000" fill="Solid" isStrikeThrough="false">
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{Wed}.contains( "OT" )]]></conditionExpression>
            <style mode="Transparent" forecolor="#FF0000"/>
        </conditionalStyle>
    </style>
    <parameter name="ReportTitle" class="java.lang.String"/>
    <parameter name="DataFile" class="java.lang.String"/>
    <parameter name="Info" class="java.lang.String">
        <parameterDescription><![CDATA[Info]]></parameterDescription>
    </parameter>
    <parameter name="CurrentDate" class="java.lang.String">
        <parameterDescription><![CDATA[CurrentDate]]></parameterDescription>
    </parameter>
    <parameter name="User" class="java.lang.String">
        <parameterDescription><![CDATA[User]]></parameterDescription>
    </parameter>
    <parameter name="Group" class="java.lang.String">
        <parameterDescription><![CDATA[Group]]></parameterDescription>
    </parameter>
    <parameter name="StartDateReport" class="java.lang.String">
        <parameterDescription><![CDATA[StartDateReport]]></parameterDescription>
    </parameter>
    <parameter name="EndDateReport" class="java.lang.String">
        <parameterDescription><![CDATA[EndDateReport]]></parameterDescription>
    </parameter>
    <parameter name="Day1" class="java.lang.String">
        <parameterDescription><![CDATA[Day1]]></parameterDescription>
    </parameter>
    <parameter name="Day2" class="java.lang.String">
        <parameterDescription><![CDATA[Day2]]></parameterDescription>
    </parameter>
    <parameter name="Day3" class="java.lang.String">
        <parameterDescription><![CDATA[Day3]]></parameterDescription>
    </parameter>
    <parameter name="Day4" class="java.lang.String">
        <parameterDescription><![CDATA[Day4]]></parameterDescription>
    </parameter>
    <parameter name="Day5" class="java.lang.String">
        <parameterDescription><![CDATA[Day5]]></parameterDescription>
    </parameter>
    <parameter name="Day6" class="java.lang.String">
        <parameterDescription><![CDATA[Day6]]></parameterDescription>
    </parameter>
    <parameter name="Day7" class="java.lang.String">
        <parameterDescription><![CDATA[Day7]]></parameterDescription>
    </parameter>
    <queryString language="xPath">
        <![CDATA[/EmpSchedule/Employee]]>
    </queryString>
    <field name="Name" class="java.lang.String">
        <fieldDescription><![CDATA[Name]]></fieldDescription>
    </field>
    <field name="Sun" class="java.lang.String">
        <fieldDescription><![CDATA[Sun]]></fieldDescription>
    </field>
    <field name="Mon" class="java.lang.String">
        <fieldDescription><![CDATA[Mon]]></fieldDescription>
    </field>
    <field name="Tue" class="java.lang.String">
        <fieldDescription><![CDATA[Tue]]></fieldDescription>
    </field>
    <field name="Wed" class="java.lang.String">
        <fieldDescription><![CDATA[Wed]]></fieldDescription>
    </field>
    <field name="Thu" class="java.lang.String">
        <fieldDescription><![CDATA[Thu]]></fieldDescription>
    </field>
    <field name="Fri" class="java.lang.String">
        <fieldDescription><![CDATA[Fri]]></fieldDescription>
    </field>
    <field name="Sat" class="java.lang.String">
        <fieldDescription><![CDATA[Sat]]></fieldDescription>
    </field>
    <field name="PriPayCatg" class="java.lang.String">
        <fieldDescription><![CDATA[PriPayCatg]]></fieldDescription>
    </field>
    <field name="Shift" class="java.lang.String">
        <fieldDescription><![CDATA[Shift]]></fieldDescription>
    </field>
    <variable name="Desc" class="java.lang.String">
        <variableExpression><![CDATA[$F{Name} + "\n" + $F{PriPayCatg}]]></variableExpression>
    </variable>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="20" splitType="Stretch">
            <textField isBlankWhenNull="true" bookmarkLevel="1">
                <reportElement key="textField" style="Arial_Normal" x="0" y="0" width="250" height="10" uuid="33cdd98f-fb0e-4734-b70e-96ef56a857e6"/>
                <box leftPadding="1">
                    <pen lineColor="#888888"/>
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#888888"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#888888"/>
                    <bottomPen lineStyle="Solid" lineColor="#888888"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                </box>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font size="8"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{ReportTitle}]]></textFieldExpression>
                <anchorNameExpression><![CDATA["Title"]]></anchorNameExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement key="textField" style="Arial_Normal" x="250" y="0" width="252" height="20" uuid="805cd85a-23a6-4929-b867-a632888162a5"/>
                <box>
                    <pen lineColor="#888888"/>
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#888888"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                    <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#888888"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{DataFile}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true" bookmarkLevel="1">
                <reportElement key="textField" style="Arial_Normal" x="0" y="10" width="250" height="10" uuid="912b47c5-8ea1-4151-b06f-75752fe035be"/>
                <box leftPadding="1">
                    <pen lineColor="#888888"/>
                    <topPen lineStyle="Solid" lineColor="#888888"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#888888"/>
                    <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#888888"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                </box>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font size="8"/>
                </textElement>
                <textFieldExpression><![CDATA["User: " + $P{User}]]></textFieldExpression>
                <anchorNameExpression><![CDATA["Title"]]></anchorNameExpression>
            </textField>
            <textField isBlankWhenNull="false">
                <reportElement key="textField" x="502" y="0" width="234" height="10" uuid="fdcaf8da-917e-4dae-ba94-e43dda0b6c70"/>
                <box>
                    <pen lineColor="#888888"/>
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#888888"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font size="8"/>
                </textElement>
                <textFieldExpression><![CDATA["Page " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report" isBlankWhenNull="false">
                <reportElement key="textField" x="736" y="0" width="16" height="10" uuid="fb85e1fd-dcc2-4a93-b6e0-3813f9400681"/>
                <box rightPadding="1">
                    <topPen lineWidth="0.5" lineColor="#888888"/>
                    <bottomPen lineColor="#888888"/>
                    <rightPen lineWidth="0.5" lineColor="#888888"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font size="8"/>
                </textElement>
                <textFieldExpression><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="502" y="10" width="250" height="10" uuid="5137d07f-a23f-45d2-b28d-7eca43fffe2d"/>
                <box rightPadding="1">
                    <pen lineColor="#888888"/>
                    <topPen lineColor="#888888"/>
                    <leftPen lineColor="#888888"/>
                    <bottomPen lineWidth="0.5" lineColor="#888888"/>
                    <rightPen lineWidth="0.5" lineColor="#888888"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font size="8"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{CurrentDate}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <pageHeader>
        <band splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="42" splitType="Stretch">
            <staticText>
                <reportElement key="staticText" style="Arial_Normal" mode="Opaque" x="0" y="27" width="97" height="15" forecolor="#000000" backcolor="#FFFF66" uuid="0613433d-fc62-450d-b0f8-b637cc2bbac0"/>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="10"/>
                </textElement>
                <text><![CDATA[Employee]]></text>
            </staticText>
            <textField isBlankWhenNull="false">
                <reportElement key="textField" x="652" y="17" width="84" height="10" uuid="82c24f36-c0f7-4a40-9f83-6b8e9c0f5dda">
                    <printWhenExpression><![CDATA[!$V{PAGE_NUMBER}.toString().equals("1")]]></printWhenExpression>
                </reportElement>
                <box>
                    <pen lineColor="#888888"/>
                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                </box>
                <textElement textAlignment="Right">
                    <font size="8"/>
                </textElement>
                <textFieldExpression><![CDATA["Page " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report" isBlankWhenNull="false">
                <reportElement key="textField" x="736" y="17" width="16" height="10" uuid="b960e0e2-b4f1-4310-b1df-e8b8baced9b3">
                    <printWhenExpression><![CDATA[!$V{PAGE_NUMBER}.toString().equals("1")]]></printWhenExpression>
                </reportElement>
                <box rightPadding="1">
                    <topPen lineWidth="0.0" lineColor="#888888"/>
                    <bottomPen lineWidth="0.0" lineColor="#888888"/>
                    <rightPen lineWidth="0.0" lineColor="#888888"/>
                </box>
                <textElement textAlignment="Right">
                    <font size="8"/>
                </textElement>
                <textFieldExpression><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement key="textField" style="Arial_Normal" x="0" y="7" width="250" height="20" uuid="68f73211-92b6-4a42-bd5e-b6be56f4507b"/>
                <box>
                    <pen lineColor="#888888"/>
                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#888888"/>
                </box>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font size="11"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{StartDateReport} + " - " + $P{EndDateReport}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement mode="Opaque" x="97" y="27" width="91" height="15" forecolor="#000000" backcolor="#FFFF66" uuid="2b12362e-7299-4a0f-8f02-d61020e709cf"/>
                <box leftPadding="2" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="1.0" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{Day1}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement mode="Opaque" x="188" y="27" width="94" height="15" forecolor="#000000" backcolor="#FFFF66" uuid="85986fe4-fc7f-4d2a-aa5b-fe84870d7148"/>
                <box leftPadding="2" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="1.0" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{Day2}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement mode="Opaque" x="282" y="27" width="94" height="15" forecolor="#000000" backcolor="#FFFF66" uuid="3eb51fc1-7b81-4402-865b-e510b2c0a99b"/>
                <box leftPadding="2" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="1.0" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{Day3}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement mode="Opaque" x="376" y="27" width="94" height="15" forecolor="#000000" backcolor="#FFFF66" uuid="bc398981-64b0-4da2-8375-92032474ad86"/>
                <box leftPadding="2" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="1.0" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{Day4}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement mode="Opaque" x="470" y="27" width="94" height="15" forecolor="#000000" backcolor="#FFFF66" uuid="bd6b4808-6655-42c0-b418-875066486974"/>
                <box leftPadding="2" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="1.0" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{Day5}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement mode="Opaque" x="564" y="27" width="94" height="15" forecolor="#000000" backcolor="#FFFF66" uuid="9a005139-6044-47b7-8dce-3f9907b641e8"/>
                <box leftPadding="2" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="1.0" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{Day6}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement mode="Opaque" x="658" y="27" width="94" height="15" forecolor="#000000" backcolor="#FFFF66" uuid="8d102092-ce9c-48b3-803b-f98c99d77852"/>
                <box leftPadding="2" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="1.0" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{Day7}]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="16">
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement key="" positionType="Float" stretchType="RelativeToTallestObject" x="282" y="0" width="94" height="16" isPrintWhenDetailOverflows="true" uuid="37ef170c-59ef-4e6f-aa3d-8b84e8ccd7b0"/>
                <box topPadding="4" leftPadding="2" bottomPadding="4" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <leftPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <bottomPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <rightPen lineWidth="0.25" lineColor="#B6B6B6"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="6"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Tue}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement key="" positionType="Float" stretchType="RelativeToTallestObject" x="188" y="0" width="94" height="16" isPrintWhenDetailOverflows="true" uuid="361acb1b-c142-453f-a3ca-05caaae66d67"/>
                <box topPadding="4" leftPadding="2" bottomPadding="4" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <leftPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <bottomPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <rightPen lineWidth="0.25" lineColor="#B6B6B6"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="6" isItalic="false"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Mon}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement key="" positionType="Float" stretchType="RelativeToTallestObject" x="564" y="0" width="94" height="16" isPrintWhenDetailOverflows="true" uuid="3f495eb4-0c62-41f2-80bf-d8dbcd94b895"/>
                <box topPadding="4" leftPadding="2" bottomPadding="4" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <leftPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <bottomPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <rightPen lineWidth="0.25" lineColor="#B6B6B6"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="6"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Fri}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement key="" positionType="Float" stretchType="RelativeToTallestObject" x="97" y="0" width="91" height="16" isPrintWhenDetailOverflows="true" uuid="bce28a62-7f90-4d44-b525-100e15efa1f9"/>
                <box topPadding="4" leftPadding="2" bottomPadding="4" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <leftPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <bottomPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <rightPen lineWidth="0.25" lineColor="#B6B6B6"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="6"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Sun}]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="true">
                <reportElement key="" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="97" height="16" isPrintWhenDetailOverflows="true" uuid="d7d2b78d-70fd-4f32-98ff-fc0442bc345d"/>
                <box leftPadding="2" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <leftPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <bottomPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <rightPen lineWidth="0.25" lineColor="#B6B6B6"/>
                </box>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font size="8" isItalic="false"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
                <reportElement key="" positionType="Float" stretchType="RelativeToTallestObject" x="658" y="0" width="94" height="16" isPrintWhenDetailOverflows="true" uuid="91600c0a-1c0f-4280-9ba2-667004e3f1ed"/>
                <box topPadding="4" leftPadding="2" bottomPadding="4" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <leftPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <bottomPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <rightPen lineWidth="0.25" lineColor="#B6B6B6"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="6"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Sat}]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="true">
                <reportElement key="" positionType="Float" stretchType="RelativeToBandHeight" mode="Transparent" x="470" y="0" width="94" height="16" isPrintWhenDetailOverflows="true" forecolor="#000000" backcolor="#FFFFFF" uuid="d22b895a-d303-4d66-8e19-1915aa221161"/>
                <box topPadding="4" leftPadding="2" bottomPadding="4" rightPadding="2">
                    <pen lineColor="#B6B6B6"/>
                    <topPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <leftPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <bottomPen lineWidth="0.25" lineColor="#B6B6B6"/>
                    <rightPen lineWidth="0.25" lineColor="#B6B6B6"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
                    <font size="6"/>
                    <paragraph lineSpacing="Single" tabStopWidth="60"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Thu}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="OT_Style" x="376" y="0" width="94" height="16" uuid="b949a9d8-9eb7-434b-be20-d1888da8945b"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="6"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Wed}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="1" splitType="Stretch">
            <line>
                <reportElement key="line" x="0" y="0" width="752" height="1" uuid="1bbf10b6-2364-48eb-9d47-b0f248cfe7f3"/>
            </line>
        </band>
    </columnFooter>
    <pageFooter>
        <band splitType="Stretch"/>
    </pageFooter>
    <lastPageFooter>
        <band splitType="Stretch"/>
    </lastPageFooter>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>

Datasource (XML)

<?xml version="1.0" encoding="UTF-8"?>
<EmpSchedule>
    <Employee>
        <Name>Alanna Black</Name>
        <Sun/>
        <Mon/>
        <Tue/>
        <Wed>10:00 AM - 2:00 PM
7:00 PM - 8:00 PM</Wed>
        <Thu/>
        <Fri/>
        <Sat/>
    </Employee>
    <Employee>
        <Name>Castor Troy</Name>
        <Sun/>
        <Mon/>
        <Tue/>
        <Wed>11:00 AM - 3:00 PM</Wed>
        <Thu/>
        <Fri/>
        <Sat/>
    </Employee>
    <Employee>
        <Name>Test Curren</Name>
        <Sun/>
        <Mon/>
        <Tue/>
        <Wed>12:00 PM - 4:00 PM
OT(12:02 PM - 4:05 PM)
8:00 PM - 10:00 PM
(8:02 PM - 10:02 PM)
        </Wed>
        <Thu/>
        <Fri/>
        <Sat/>
    </Employee>
    <Employee>
        <Name>Andrew Mind</Name>
        <Sun/>
        <Mon/>
        <Tue/>
        <Wed>1:00 PM - 5:00 PM</Wed>
        <Thu/>
        <Fri/>
        <Sat/>
    </Employee>
</EmpSchedule>

alfie1109 - 5 years 2 months ago

Did you try upgrading ireport to Jasper Studio ? and see if this problem still persists 

ireport is not supported anymore and it has been replaced with Jasper Studio quite awhile ago. 

reportdev - 5 years 2 months ago

No, not yet.  But I went different direction and I got it to work.  I used list component and restructed my xml file.

Thank you for your reply.

alfie1109 - 5 years 2 months ago

2 Answers:

I think you have left the Transparent checkbox checked on the conditionalStyle. 

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.2.final using JasperReports Library version 6.4.1  -->
<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="color" pageWidth="595" pageHeight="842" columnWidth="555"
              leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"
              uuid="064063bc-a18b-49e3-a8c6-8679cddd63fb">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <style name="Style1">
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{ID}.contains("OT")]]></conditionExpression>
            <style mode="Opaque" backcolor="#FF0400"/>
        </conditionalStyle>
    </style>
    <queryString>
        <![CDATA[select 'OT(12:02 PM - 4:05 PM)' as ID from dual
union all
select '12:00 PM - 4:00 PM' as ID from dual]]>
    </queryString>
    <field name="ID" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="35" splitType="Stretch">
            <textField>
                <reportElement style="Style1" x="0" y="0" width="180" height="30"
                               uuid="3cfb97fe-f626-4238-9c06-6fa831c1a04a"/>
                <textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>
reportdev's picture
12948
Joined: Oct 12 2015 - 12:05pm
Last seen: 1 year 3 months ago

I used a list component and re-structured my xml file to accomplish what I wanted to do.

Ref:
https://community.jaspersoft.com/questions/1101621/how-call-attribute-xml-file-and-use-it-condition-expression

alfie1109's picture
419
Joined: Jul 23 2018 - 11:13am
Last seen: 4 years 10 months ago
Feedback
randomness