【发布时间】:2017-01-19 04:49:09
【问题描述】:
我正在尝试将碧玉报告导出到 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>
注意:我正在获取标题的背景颜色,但不在列标题和详细信息中。
【问题讨论】:
-
你可以在this question阅读@mdahlman的回答
-
@Alex 问题和答案与背景图像有关,而我的问题与背景颜色有关。
-
您可能需要发布一些 .jrxml。听起来您从概念上理解事物,但报告定义中存在某种错误。
-
@mdahlman hmm.. 如果 jrxml 报告中有错误,jasperviewer 也不应该出现。但我能够在 jasper 查看器中获得所需的输出,但不能在 html 中获得。找到添加的jrxml代码。注意:这是使用 iReports 生成的
-
这是一个很好的观点。生成 XHTML 时会得到什么?这可能是 HTML 导出器的限制。尝试为每个文本元素设置背景颜色(现在您只为框架设置了背景颜色)。
标签: java jasper-reports