我使用jaspersoft studio并正在创建一个交叉表。如何根据值更改字体颜色?。
所以当它为0时我希望它是红色的,如果它的1然后是橙色,则高于2 绿色。
我尝试了不同的例子,但它们引用了普通报告中的变量。这怎么可能在交叉。并且通过添加hteir样式表我不断得到java错误,因为crostab中显示的计数值不是变量而是度量。 " $ V {COLUMN_5_MEASURE1}"
我现在被卡住了!!
当前的jrxml代码
这是交叉表代码。
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 -->
<!-- 2016-01-14T10:33:46 -->
<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" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0eac5564-7241-4ddc-9c70-3dd9e65d8fcd">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>
<style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CG" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CT" mode="Opaque" backcolor="#005FB3">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Style1">
<conditionalStyle>
<conditionExpression><![CDATA[<style name="ZFieldStyle">
<conditionalStyle>
<conditionExpression><![CDATA[$F{Z} < $F{Y}]]]]><![CDATA[></conditionExpression>
<style forecolor="#000000"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$F{Z}>$F{X}]]]]><![CDATA[></conditionExpression>
<style forecolor="#FF0000"/>
</conditionalStyle>
</style>
...
<field name="X" class="java.lang.Integer"/>
...
<textField>
<reportElement style="ZFieldStyle" x="200" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{Z}]]]]><![CDATA[></textFieldExpression>
</textField>]]></conditionExpression>
<style/>
</conditionalStyle>
</style>
<queryString>
<![CDATA[SELECT
`accounts`.`name`
, `accounts`.`id`
,users.`user_name`
, DATE(`calls`.`date_entered`)
,calls.`id`
FROM
`d101`.`calls`
INNER JOIN `d101`.`calls_contacts`
ON (`calls`.`id` = `calls_contacts`.`call_id`)
INNER JOIN `d101`.`accounts_contacts`
ON (`calls_contacts`.`contact_id` = `accounts_contacts`.`contact_id`)
INNER JOIN `d101`.`accounts`
ON (`accounts_contacts`.`account_id` = `accounts`.`id`)
INNER JOIN users ON calls.`created_by` = users.`id`
;]]>
</queryString>
<field name="name" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="id" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="user_name" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="DATE(`calls`.`date_entered`)" class="java.sql.Date"/>
<field name="COLUMN_5" class="java.lang.String"/>
<variable name="CustSaIndex" class="java.lang.String" calculation="Count">
<variableExpression><![CDATA[$F{COLUMN_5}]]></variableExpression>
</variable>
<variable name="CustSatIndex_Individual" class="java.lang.String" calculation="Count">
<variableExpression><![CDATA[$F{COLUMN_5}]]></variableExpression>
</variable>
<group name="name">
<groupExpression><![CDATA[$F{name}]]></groupExpression>
</group>
<group name="user_name">
<groupExpression><![CDATA[$F{user_name}]]></groupExpression>
</group>
<group name="DATE(`calls`.`date_entered`)">
<groupExpression><![CDATA[$F{DATE(`calls`.`date_entered`)}]]></groupExpression>
</group>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="211" splitType="Stretch">
<crosstab>
<reportElement x="0" y="0" width="555" height="211" uuid="732a68fe-ddda-45e2-b3be-9dd21bd70ada">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
</reportElement>
<rowGroup name="user_name1" width="60" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{user_name}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="40" uuid="934d5cd7-7860-4413-8612-ae4147d9802e"/>
<textFieldExpression><![CDATA[$V{user_name1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents mode="Opaque" style="Crosstab_CT">
<staticText>
<reportElement x="0" y="0" width="120" height="20" forecolor="#FFFFFF" uuid="3046862c-61c7-43d9-a379-d0afbed45073"/>
<text><![CDATA[Total user_name1]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<rowGroup name="name1" width="60" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{name}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="9b25a91d-34a1-49ab-bade-c0f09b58fc05"/>
<textFieldExpression><![CDATA[$V{name1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents mode="Opaque" style="Crosstab_CG">
<staticText>
<reportElement x="0" y="0" width="60" height="20" uuid="1939170d-5e2b-4e73-81c0-f2409ddd822d"/>
<text><![CDATA[Total name1]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="DATE(`calls`.`date_entered`)1" height="20" totalPosition="End">
<bucket class="java.sql.Date">
<bucketExpression><![CDATA[$F{DATE(`calls`.`date_entered`)}]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="050d35f6-e7a8-4108-925f-6957c5a5a17d"/>
<textFieldExpression><![CDATA[$V{DATE(`calls`.`date_entered`)1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CT">
<staticText>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="0e258a6a-daff-4b4b-8c23-27b515b7cf15"/>
<text><![CDATA[Total DATE(`calls`.`date_entered`)1]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
这是我需要在字段值计数条件下更改的字段!
<measure name="COLUMN_5_MEASURE1" class="java.lang.Integer" calculation="Count">
<measureExpression><![CDATA[$F{COLUMN_5}]]></measureExpression>
</measure>
<crosstabCell width="60" height="20">
<cellContents mode="Opaque" style="Crosstab_CD">
<textField>
<reportElement style="Crosstab_CG" x="0" y="0" width="60" height="20" uuid="d2eadf60-bf5e-46bd-a76c-09bdd755cca3"/>
<textFieldExpression><![CDATA[$V{COLUMN_5_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" columnTotalGroup="DATE(`calls`.`date_entered`)1">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="cf6c0dfc-b2b9-4590-bab2-3b83c619d243"/>
<textFieldExpression><![CDATA[$V{COLUMN_5_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="user_name1">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="d8c569e9-790b-4f56-ae33-46a2f84eac08"/>
<textFieldExpression><![CDATA[$V{COLUMN_5_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="user_name1" columnTotalGroup="DATE(`calls`.`date_entered`)1">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="bc54fe2a-7b4b-419e-ba9d-6b4b084e45e9"/>
<textFieldExpression><![CDATA[$V{COLUMN_5_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="name1">
<cellContents mode="Opaque" style="Crosstab_CG">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="d25d3d53-bba9-4af5-97d5-6f81e06249d8"/>
<textFieldExpression><![CDATA[$V{COLUMN_5_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="name1" columnTotalGroup="DATE(`calls`.`date_entered`)1">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="fd227041-65f9-4056-af4d-fdd8b150c190"/>
<textFieldExpression><![CDATA[$V{COLUMN_5_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
</crosstab>
</band>
</summary>
</jasperReport>