Reputation: 654
I'm trying to export jasper report to html. My title,detail band column headers has background colors. The report has all the colors when I am checking it in jasperviewer, but after exporting to html the background colors in the html reports are not getting displayed.(only for detail) They are not there even in the source code.
?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>
NOTE: I'm getting the background color for title but not in column header and detail.
Upvotes: 2
Views: 3536
Reputation: 4934
Ran into similar issue with excel export. It turns out the export only supports certain color palettes. You'll have to look for html exporter color palette and change your colors to one that on that list.
Upvotes: 2