JasperReports:不能使用positionType ='Float'的子报表 [英] JasperReports: subreports not working with positionType='Float'

查看:107
本文介绍了JasperReports:不能使用positionType ='Float'的子报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个例子中的子报告重叠 - 我做错了什么?第二个应该浮动在第一个之下,其'y'属性被忽略,但它不是。

Subreports overlap in this example -- what am I doing wrong? The second one is supposed to "float" below the first one, with its 'y' attribute being ignored, but it isn't.

谢谢!!

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report name" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["C:\\reportFolder\\"]]></defaultValueExpression>
    </parameter>
    <background>
        <band/>
    </background>
    <detail>
        <band height="200">
            <subreport>
                <reportElement positionType="FixRelativeToTop" x="19" y="0" width="200" height="50"/>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
                <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "report1.jasper"]]></subreportExpression>
            </subreport>
            <subreport>
                <reportElement positionType="Float" mode="Transparent" x="19" y="20" width="200" height="50" backcolor="#FFFF66"/>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
                <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "report1.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
</jasperReport>


推荐答案

我得到了答案! (我是那个问过的人,我猜不同的IP)
根据文档,浮动元素将忽略其y属性。我从字面上理解,尝试了y的任意值,并且每次将元素放置在指定位置时都会看到。

I got the answer! (I'm the one who asked, different IP I guess) According to the documentation, the floating element would have its y attribute ignored. I had taken that literally, tried arbitrary values for y and saw that everytime the element was placed at the specified position.

但不,你需要设置y来定位元素正好位于前一个元素的下方,根据该元素声明的y和高度,即使填充数据时其实际高度可以拉伸。在我的示例代码中,第二个子报表应该有y =50。

But no, you need to set y to position the element right below the previous one, according to that element's declared y and height, even though its actual height could be stretched when filled with data. In my sample code, the second subreport should have had y="50".

此外,我看到元素的声明高度被视为最小高度。如果实际子报表短于高度,则封闭元素不会缩小,因此最好设置可以拉伸的元素的最小预期高度。

Furthermore, I see that the declared height of an element is taken as a minimum height. If the actual subreport is shorter than the height, the enclosing element won't be shrunk, so it would be a good idea to set the minimum expected height for elements that could be stretched.

这篇关于JasperReports:不能使用positionType ='Float'的子报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆