1) Style
2) Condition-1
3) Condition-2
4) On the Text Field
5) Output
6) JRXML
1) Style
2) Condition-1
3) Condition-2
4) On the Text Field
5) Output
6) JRXML
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0 -->
<!-- 2015-03-06T13:13:06 -->
<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="Blank_A4_22" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ab524a87-197a-4dac-b294-ba81b7cb1409">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<style name="Style1">
<conditionalStyle>
<conditionExpression><![CDATA[$F{unitsales}.doubleValue()>=0 && $F{unitsales}.doubleValue()<=1000]]></conditionExpression>
<style backcolor="#7679B0"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$F{unitsales}.doubleValue()>1000 && $F{unitsales}.doubleValue()<=3000]]></conditionExpression>
<style backcolor="#EBEDA4"/>
</conditionalStyle>
</style>
<queryString>
<![CDATA[SELECT c.city, SUM(unit_sales) UnitSales FROM customer c, sales_fact_1997 sf7 WHERE
c.customer_id=sf7.customer_id GROUP BY c.city]]>
</queryString>
<field name="city" class="java.lang.String"/>
<field name="unitsales" class="java.math.BigDecimal"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="32" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="36" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="278" height="30" uuid="621ecd38-7026-4d55-9afe-6a1fa2c37613"/>
<text><![CDATA[city]]></text>
</staticText>
<staticText>
<reportElement x="278" y="0" width="277" height="30" uuid="2c237fac-2804-4031-a064-a666b37fd164"/>
<text><![CDATA[unitsales]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="46" splitType="Stretch">
<textField>
<reportElement x="0" y="13" width="278" height="30" uuid="a448fd0f-d6b7-45ef-8915-3250c06d178a"/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Style1" mode="Opaque" x="278" y="13" width="277" height="30" uuid="2040c97e-9bd0-4c05-b515-a06f60b315af"/>
<textFieldExpression><![CDATA[$F{unitsales}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
2) Condition-1
3) Condition-2
4) On the Text Field
5) Output
6) JRXML
1) Style
2) Condition-1
3) Condition-2
4) On the Text Field
5) Output
6) JRXML
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0 -->
<!-- 2015-03-06T13:13:06 -->
<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="Blank_A4_22" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ab524a87-197a-4dac-b294-ba81b7cb1409">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart"/>
<style name="Style1">
<conditionalStyle>
<conditionExpression><![CDATA[$F{unitsales}.doubleValue()>=0 && $F{unitsales}.doubleValue()<=1000]]></conditionExpression>
<style backcolor="#7679B0"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$F{unitsales}.doubleValue()>1000 && $F{unitsales}.doubleValue()<=3000]]></conditionExpression>
<style backcolor="#EBEDA4"/>
</conditionalStyle>
</style>
<queryString>
<![CDATA[SELECT c.city, SUM(unit_sales) UnitSales FROM customer c, sales_fact_1997 sf7 WHERE
c.customer_id=sf7.customer_id GROUP BY c.city]]>
</queryString>
<field name="city" class="java.lang.String"/>
<field name="unitsales" class="java.math.BigDecimal"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="32" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="36" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="278" height="30" uuid="621ecd38-7026-4d55-9afe-6a1fa2c37613"/>
<text><![CDATA[city]]></text>
</staticText>
<staticText>
<reportElement x="278" y="0" width="277" height="30" uuid="2c237fac-2804-4031-a064-a666b37fd164"/>
<text><![CDATA[unitsales]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="46" splitType="Stretch">
<textField>
<reportElement x="0" y="13" width="278" height="30" uuid="a448fd0f-d6b7-45ef-8915-3250c06d178a"/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Style1" mode="Opaque" x="278" y="13" width="277" height="30" uuid="2040c97e-9bd0-4c05-b515-a06f60b315af"/>
<textFieldExpression><![CDATA[$F{unitsales}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
That's great - the Jasper forum says that not getting a background fill in conditional formatting is a bug. Following your method above works.
ReplyDeleteOne question - is there a way to get that "checkered" look for a non-selected color once you've selected a color? As shown in the Forecolor and Backcolor in the first step.