0

如果列类型是 Image,DynamicJasper 不会应用条件样式。此错误适用于 setPrintBackgroundOnOddRows 和 addConditionalStyle()

如果您打印出 jrxml 文件,则图像列的样式缺少 conditionalStyle 标记。

Style oddRowStyle = new Style();
oddRowStyle.setBackgroundColor(Color.LIGHT_GRAY);

oddRowStyle.setTransparency(Transparency.OPAQUE);

FastReportBuilder reportTemplate = new FastReportBuilder();
reportTemplate.setPrintBackgroundOnOddRows(true)
.setPageSizeAndOrientation(Page.Page_A4_Landscape())
.setOddRowBackgroundStyle(oddRowStyle);

AbstractColumn columnSqlServer = ColumnBuilder.getNew().setColumnProperty(columnProperty.getKey(), Object.class.getName())
                .setColumnType(ColumnBuilder.COLUMN_TYPE_IMAGE)
                .setImageScaleMode(ImageScaleMode.NO_RESIZE)
                //.addConditionalStyle(new ConditionalStyle(new FetchCondition(), columnStyle1)) 
                .setStyle(columnStyle)
                .setHeaderStyle(headerStyle).build();

从生成的 jxml 文件

<style name="dj_style_3_" mode="Transparent" forecolor="#000000" backcolor="#FFFFFF" radius="0" hAlign="Center" vAlign="Middle" rotation="None" isBlankWhenNull="true" fontName="Verdana" fontSize="8" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded="false">
    <box padding="2">
        <pen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
    </box>
</style>
<style name="dj_style_4_" mode="Transparent" forecolor="#000000" backcolor="#FFFFFF" radius="0" hAlign="Left" vAlign="Middle" rotation="None" isBlankWhenNull="true" fontName="Verdana" fontSize="8" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded="false">
    <box padding="2">
        <pen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
    </box>
</style>

奇偶数列

<style name="Verdana_for_column_DJR_3169_COLUMN_1_" mode="Transparent" forecolor="#000000" backcolor="#FFFFFF" radius="0" hAlign="Left" vAlign="Middle" rotation="None" isBlankWhenNull="true" fontName="Verdana" fontSize="8" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded="false">
    <box padding="2">
        <pen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
    </box>
    <conditionalStyle>
        <conditionExpression><![CDATA[new java.lang.Boolean(((Number)$V{REPORT_COUNT}).doubleValue() % 2 == 0)]]></conditionExpression>
        <style mode="Opaque" backcolor="#C0C0C0"/>
    </conditionalStyle>
</style>

它缺少标签

4

0 回答 0