我正在尝试将jasper报告导出为html。我的标题,细节带列标题有背景颜色。当我在jasperviewer中检查时,报告具有所有颜色,但在导出到html后,html报告中的背景颜色不会显示。(仅用于详细信息)它们即使在源代码中也不存在。
?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
name="monthlyStats" pageWidth="595" pageHeight="400" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#1E90FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE0FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#1E90FF">
<box>
<topPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFE0FF">
<box>
<topPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<topPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFF7FF"/>
</conditionalStyle>
</style>
<style name="table 2">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TH" mode="Opaque" backcolor="#000000">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_CH" mode="Opaque" backcolor="#FFE6E6">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 1"/>
<subDataset name="Table Dataset 2"/>
<subDataset name="Table Dataset 3"/>
<parameter name="devicename" class="java.lang.String" />
<queryString>
<![CDATA[select DATEPART(MONTH,rm_devus_enddt) as month,
CASE when DATEPART(MONTH,rm_devus_enddt)=2
then
SUM((DATEDIFF(HOUR,rm_devus_startdt,rm_devus_enddt)*100.0)/(28.0*24.0))
else
CASE when (DATEPART(MONTH,rm_devus_enddt)%2)!=0
then
SUM((DATEDIFF(HOUR,rm_devus_startdt,rm_devus_enddt)*100.0)/(31.0*24.0))
else
SUM((DATEDIFF(HOUR,rm_devus_startdt,rm_devus_enddt)*100.0)/(30.0*24.0))
end
end as freepercent
from deviceusage where rm_device_id=(select rm_device_id from device where rm_device_name=$P{devicename})
and rm_devus_enddt is not NULL GROUP BY DATEPART(MONTH,rm_devus_enddt);]]>
</queryString>
<field name="month" class="java.lang.Integer"/>
<field name="freepercent" class="java.math.BigDecimal"/>
<background>
<band/>
</background>
<title>
<band height="41">
<frame>
<reportElement mode="Opaque" x="-20" y="-26" width="595" height="53" backcolor="#006699"/>
<image>
<reportElement x="0" y="5" width="225" height="48"/>
<imageExpression><![CDATA["../logo/RDLOGO.JPG"]]></imageExpression>
</image>
</frame>
<rectangle>
<reportElement x="-20" y="33" width="595" height="5" forecolor="#006699" backcolor="#006699"/>
</rectangle>
</band>
</title>
<pageHeader>
<band/>
</pageHeader>
<columnHeader>
<band height="67">
<frame>
<reportElement mode="Opaque" x="16" y="34" width="511" height="33" forecolor="#006699" backcolor="#000000"/>
</frame>
<staticText>
<reportElement x="58" y="47" width="100" height="20" forecolor="#F0F0F0" />
<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
<font size="13" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
</textElement>
<text><![CDATA[Month]]></text>
</staticText>
<staticText>
<reportElement x="221" y="47" width="100" height="20" forecolor="#F0F0F0" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="13" isBold="true"/>
</textElement>
<text><![CDATA[%free]]></text>
</staticText>
<staticText>
<reportElement x="371" y="47" width="100" height="20" forecolor="#F0F0F0" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="13" isBold="true"/>
</textElement>
<text><![CDATA[%used]]></text>
</staticText>
</band>
</columnHeader>
注意:我获得了标题的背景颜色,但没有列标题和详细信息。
答案 0 :(得分:2)
与excel导出类似的问题。事实证明,导出仅支持某些调色板。您必须查找html导出器调色板并将颜色更改为该列表中的颜色。