Java Jasper报告到html不显示背景色

Java Jasper报告到html不显示背景色,java,jasper-reports,Java,Jasper Reports,我正在尝试将jasper报告导出为html。“我的标题”、“详细信息”栏标题具有背景色。当我在jasperviewer中检查报告时,报告具有所有颜色,但在导出到html后,html报告中的背景颜色不会显示出来(仅用于详细说明),甚至在源代码中也没有 ?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://j

我正在尝试将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>
?xml version=“1.0”encoding=“UTF-8”>

注意:我得到的是标题的背景色,但不是列标题和详细信息。

在excel导出中遇到类似问题。事实证明,导出只支持某些调色板。您必须查找html exporter调色板,并将颜色更改为该列表中的颜色。

您可以阅读@Alex上的@mdahlman的答案,该问答与背景图像相关,我的问题与背景颜色相关。您可能需要发布一些.jrxml。听起来你从概念上理解了事情,但报告定义中有某种缺陷。@mdahlman-hmm。。如果jrxml报告中有bug,那么jasperviewer也不应该有bug。但我能够在jasper viewer中获得所需的输出,但不能在html中获得。查找添加的jrxml代码。注意:这是使用iReports生成的,这是一个很好的观点。生成XHTML时会得到什么?这可能是HTML导出器的一个限制。尝试为每个文本元素设置背景色(现在只为框架设置了背景色)。