如何水平显示自定义数量的元素? [英] How to display a custom number of elements horizontally?

查看:108
本文介绍了如何水平显示自定义数量的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想水平显示元素(在一个行中)。我想象这个问题就像一个有一行和动态列数的表。此表中的每个单元格包含相同的子报表但具有不同的数据源。

I want to display elements horizontally (in one "line"). I'm imagining this problem like a table with one row and dynamic number of columns. Each cell in this table contains the same subreport but with different data source.

在开始时,我尝试组合组件列表和子报表。但事实证明,列表组件不支持水平布局。我在某处读到了使用交叉表。但是,当我尝试将子报表插入度量单元格时,iReport会显示一条消息,表示我无法执行此操作。那么我该怎么办?

At the beginning I was trying combining a component list and the subreport. But it turned out that the list component doesn't support a horizontal layout. I read somewhere to use the crosstab instead. But when I'm trying to insert the subreport into a measure cell iReport displays a message that I can't do it. So what can I do?

推荐答案

根据您的上述评论,我会说打印清单并不困难水平的元素。 List组件基本上是子报表。因此,您还可以创建自定义List组件,该组件可以水平打印元素列表。您只需要创建一个没有任何边距的新报表,将其设置为打印订单水平并设置列数根据您的要求。然后,您可以将此报表作为子报表嵌入到某些主报表和水平打印元素中。

Based on your above comment, I would say that it is not that difficult to print a list of elements horizontally. A List component is basically a subreport. So, you could also create a custom List component, which prints a list of elements horizontally. All you need is to create a new report without any margins, set it's "Print Order" to "Horizontal" and set the number of columns as per your requirements. You could then embed this report as subreport in some main report and print elements horizontally.

根据您的要求,您可以相应地设置报表和文本字段大小。这是我创建的报告的屏幕截图:

Based on your requirements, you can set the report and text-field sizes accordingly. Here's the screenshot for that report I created:

这是我创建的示例jrxml文档:

And here's the sample jrxml document that I created:

<?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" columnCount="5" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="119" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band splitType="Stretch"/>
    </title>
    <pageHeader>
        <band splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="20" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="100" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{field}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>

这篇关于如何水平显示自定义数量的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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