当前位置: 动力学知识库 > 问答 > 编程问答 >

formatting - Excel export cell background color

问题描述:

I am using iReport 5.6 and when I set conditional formatting for cells in a table preview in iReport works ok

When I save as xls document the table is shown the cells are colored and values are in the cells but they (values) are not displayed. If I set cell color to normal I can see the values. Any ideas how to fix it. Either in Excel or iReport (preferably)?

my xml

 <?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="test_tabelegrafi" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">

<property name="ireport.zoom" value="1.4641000000000006"/>

<property name="ireport.x" value="0"/>

<property name="ireport.y" value="92"/>

<style name="table" lineSpacing="Single">

<box>

<pen lineWidth="1.0" lineColor="#000000"/>

</box>

</style>

<style name="table_TH" mode="Opaque" backcolor="#F0F8FF" lineSpacing="Single">

<box>

<pen lineWidth="0.5" lineColor="#000000"/>

</box>

</style>

<style name="table_CH" mode="Opaque" backcolor="#BFE1FF" lineSpacing="Single">

<box>

<pen lineWidth="0.5" lineColor="#000000"/>

</box>

</style>

<style name="table_TD" mode="Opaque" backcolor="#FFFFFF" lineSpacing="Single">

<box>

<pen lineWidth="0.5" lineColor="#000000"/>

</box>

</style>

<style name="barva_rdeca" mode="Transparent" forecolor="#000000" backcolor="#FFFFFF" lineSpacing="Single" pattern="">

<conditionalStyle>

<conditionExpression><![CDATA[$F{count} > 100]]></conditionExpression>

<style mode="Opaque" backcolor="#FF0000" fill="Solid" lineSpacing="Single"/>

</conditionalStyle>

<conditionalStyle>

<conditionExpression><![CDATA[$F{count} <= 100]]></conditionExpression>

<style mode="Opaque" backcolor="#00CC33" fill="Solid" lineSpacing="Single"/>

</conditionalStyle>

</style>

<subDataset name="New Dataset 2">

<queryString>

<![CDATA[select

o_teacher,

o_class,

o_location,

count(*)

from outputs_txt

where o_date between '2014-05-30' and '2014-06-30' and o_class != '' and o_location is not null

group by o_teacher, o_class,o_location

order by o_class,o_teacher

limit 10]]>

</queryString>

<field name="o_teacher" class="java.lang.String"/>

<field name="o_class" class="java.lang.String"/>

<field name="o_location" class="java.lang.String"/>

<field name="count" class="java.lang.Long"/>

</subDataset>

<subDataset name="Graf">

<queryString>

<![CDATA[select

o_teacher,

o_class,

o_location,

count(*)

from outputs_txt

where o_date between '2014-05-30' and '2014-06-30' and o_class != '' and o_location is not null

and o_location IN ('tel1','tel2', 'tel3')

group by o_teacher, o_class,o_location

order by o_class,o_teacher

limit 10]]>

</queryString>

<field name="o_teacher" class="java.lang.String"/>

<field name="o_class" class="java.lang.String"/>

<field name="o_location" class="java.lang.String"/>

<field name="count" class="java.lang.Long"/>

</subDataset>

<queryString>

<![CDATA[select

o_teacher,

o_class,

o_location,

count(*)

from outputs_txt

where o_date between '2014-05-30' and '2014-06-30' and o_class != '' and o_location is not null

group by o_teacher, o_class,o_location

order by o_class,o_teacher

limit 10]]>

</queryString>

<field name="o_teacher" class="java.lang.String"/>

<field name="o_class" class="java.lang.String"/>

<field name="o_location" class="java.lang.String"/>

<field name="count" class="java.lang.Long"/>

<background>

<band splitType="Stretch"/>

</background>

<title>

<band height="79" splitType="Stretch">

<staticText>

<reportElement x="154" y="0" width="234" height="38"/>

<textElement textAlignment="Center" lineSpacing="Single">

<font size="14"/>

</textElement>

<text><![CDATA[TESTNI REPORT TABEL IN GRAFOV]]></text>

</staticText>

</band>

</title>

<pageHeader>

<band height="287" splitType="Stretch">

<componentElement>

<reportElement key="table" style="barva_rdeca" stretchType="RelativeToBandHeight" x="0" y="0" width="555" height="118"/>

<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">

<datasetRun subDataset="New Dataset 2">

<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>

</datasetRun>

<jr:column width="90">

<jr:columnHeader style="table_CH" height="30" rowSpan="1">

<staticText>

<reportElement x="0" y="0" width="90" height="30"/>

<textElement lineSpacing="Single"/>

<text><![CDATA[o_teacher]]></text>

</staticText>

</jr:columnHeader>

<jr:detailCell style="table_TD" height="20" rowSpan="1">

<textField>

<reportElement x="0" y="0" width="90" height="20"/>

<textElement lineSpacing="Single"/>

<textFieldExpression class="java.lang.String"><![CDATA[$F{o_teacher}]]></textFieldExpression>

</textField>

</jr:detailCell>

</jr:column>

<jr:column width="90">

<jr:columnHeader style="table_CH" height="30" rowSpan="1">

<staticText>

<reportElement x="0" y="0" width="90" height="30"/>

<textElement lineSpacing="Single"/>

<text><![CDATA[o_class]]></text>

</staticText>

</jr:columnHeader>

<jr:detailCell style="table_TD" height="20" rowSpan="1">

<textField>

<reportElement x="0" y="0" width="90" height="20"/>

<textElement textAlignment="Center" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String"><![CDATA[$F{o_class}]]></textFieldExpression>

</textField>

</jr:detailCell>

</jr:column>

<jr:column width="90">

<jr:columnHeader style="table_CH" height="30" rowSpan="1">

<staticText>

<reportElement x="0" y="0" width="90" height="30"/>

<textElement lineSpacing="Single"/>

<text><![CDATA[o_location]]></text>

</staticText>

</jr:columnHeader>

<jr:detailCell style="table_TD" height="20" rowSpan="1">

<textField>

<reportElement x="0" y="0" width="90" height="20"/>

<textElement textAlignment="Center" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String"><![CDATA[$F{o_location}]]></textFieldExpression>

</textField>

</jr:detailCell>

</jr:column>

<jr:column width="90">

<jr:columnHeader style="table_CH" height="30" rowSpan="1">

<staticText>

<reportElement x="0" y="0" width="90" height="30"/>

<textElement lineSpacing="Single"/>

<text><![CDATA[count]]></text>

</staticText>

</jr:columnHeader>

<jr:detailCell style="table_TD" height="20" rowSpan="1">

<textField>

<reportElement style="barva_rdeca" x="0" y="0" width="90" height="20"/>

<textElement textAlignment="Center" lineSpacing="Single" markup="none"/>

<textFieldExpression class="java.lang.String"><![CDATA[$F{count}]]></textFieldExpression>

</textField>

</jr:detailCell>

</jr:column>

</jr:table>

</componentElement>

<bar3DChart>

<chart>

<reportElement positionType="Float" x="0" y="141" width="555" height="146"/>

<chartTitle/>

<chartSubtitle/>

<chartLegend/>

</chart>

<categoryDataset>

<dataset>

<datasetRun subDataset="Graf">

<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>

</datasetRun>

</dataset>

<categorySeries>

<seriesExpression><![CDATA[$F{o_location}]]></seriesExpression>

<categoryExpression><![CDATA[$F{o_teacher}]]></categoryExpression>

<valueExpression><![CDATA[$F{count}]]></valueExpression>

</categorySeries>

</categoryDataset>

<bar3DPlot>

<plot/>

<itemLabel/>

<categoryAxisFormat>

<axisFormat/>

</categoryAxisFormat>

<valueAxisFormat>

<axisFormat/>

</valueAxisFormat>

</bar3DPlot>

</bar3DChart>

</band>

</pageHeader>

<columnHeader>

<band splitType="Stretch"/>

</columnHeader>

<detail>

<band splitType="Stretch"/>

</detail>

<columnFooter>

<band splitType="Stretch"/>

</columnFooter>

<pageFooter>

<band splitType="Stretch"/>

</pageFooter>

<summary>

<band height="42" splitType="Stretch"/>

</summary>

</jasperReport>

网友答案:

The only solution I could find was that after export I selected the cells in Excel and changed type to Numeric or smth other then custom.

分享给朋友:
您可能感兴趣的文章:
随机阅读: