gpt4 book ai didi

jasper-reports - 如何创建列表控件,jr :list in two columns?

转载 作者:行者123 更新时间:2023-12-04 06:39:36 35 4
gpt4 key购买 nike

我有一个 jasper 报告列表控件,我从后端获取动态值。我需要在两列中显示列表值。

我该怎么做?

这是我的jr:list

代码
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Horizontal">
<datasetRun subDataset="accessorialsDataset" uuid="b0e600e0-5797-42b4-8078-12dd4231dd3d">
<dataSourceExpression><![CDATA[$P{accessorialDataSource}]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="12" width="524">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="0" y="0" width="259" height="12" uuid="221d3ff4-39a7-4ddd-bc74-50bed600819b"/>
<textElement>
<font fontName="Liberation Sans" size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{accessorial}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>

最佳答案

要在jr:list组件上实现多列设置printOrder="Horizo​​ntal",然后指定jr:listContents宽度为包含 jr:list

的 reportElement 所需的列数的倍数

2 列示例

<?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="2 columns" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="308cb8ae-e40a-45f4-a347-c6fcdad320b1">
<subDataset name="Dataset" uuid="ad0d45f0-00f0-495c-bff4-ae70340e05d4">
<queryString>
<![CDATA[]]>
</queryString>
<field name="_THIS" class="java.lang.String"/>
</subDataset>
<queryString>
<![CDATA[]]>
</queryString>
<summary>
<band height="30">
<componentElement>
<reportElement x="0" y="0" width="550" height="30" uuid="f811df99-b6ad-4157-a818-42ed4b77c2f0"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Horizontal">
<datasetRun subDataset="Dataset" uuid="30dc2e8a-06f9-4ecf-aa8d-66d5edd6fb95">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource(java.util.Arrays.asList("Item1;Item2;Item3;Item4".split(";")))]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="30" width="275">
<textField>
<reportElement x="0" y="0" width="270" height="30" uuid="2500a411-7ad6-4148-958f-34dfae2c9346"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{_THIS}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</summary>
</jasperReport>

Note: printOrder="Horizontal" and that jr:listContents width="275" is 1/2 of the reportElement's width="550"

输出

result

关于jasper-reports - 如何创建列表控件,jr :list in two columns?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54077528/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com