Java Jasper 报告表中的自动行号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18078343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:14:00  来源:igfitidea点击:

Auto row number in Jasper Report Table

javajasper-reports

提问by Zaw Than oo

I have a table which have No, Name, Address, Phone, Email columns. I would like set auto number in Nocolumn without parameter passing form my java class. Is there ELor something to solve it in JasperReport. I am using version 5.1.

我有一个表,其中包含 No、Name、Address、Phone、Email 列。我想在No列中设置自动编号而不从我的 java 类传递参数。有EL什么可以解决的JasperReport。我正在使用 5.1 版。

Note : As simple table, I did not provide the source and template.

注意:作为简单的表格,我没有提供源和模板。

采纳答案by Nidhish Krishnan

Try this

尝试这个

put a text-field and under the expression editor paste this $V{REPORT_COUNT}and save and run the jasper jrxml

放置一个文本字段并在表达式编辑器下粘贴它$V{REPORT_COUNT}并保存并运行 jasper jrxml

$V{REPORT_COUNT}is a Built-in Variable.

$V{REPORT_COUNT}是一个内置变量。

Set the text field's evaluation time to "Report" if you're interested in the final value.

如果您对最终值感兴趣,请将文本字段的评估时间设置为“报告”。

回答by Mayur Bhokase

We can also print alphabets instead of integer values. i.e. We can print a,b,c... instead 1,2,3...

我们还可以打印字母而不是整数值。即我们可以打印 a,b,c... 而不是 1,2,3...

For that we need to pass a List of alphabets which you want to print for sequence number, here I am going to use following code to create character list,

为此,我们需要传递一个您要打印的字母列表作为序列号,在这里我将使用以下代码来创建字符列表,

List<String> characters = new ArrayList<String>(26);
for (char c = 'a'; c <= 'z' ; c++) {
    characters.add(String.valueOf(c));
}                 
parametersMap.put("charactersList", characters);

Now, in Design add the following Expression to display the result in Alphabets instead Numbers,

现在,在设计中添加以下表达式以显示字母而不是数字的结果,

<textFieldExpression><![CDATA[$P{charactersList}.get(($V{REPORT_COUNT}-1)%26)]]></textFieldExpression>

This will render the sequence as alphabets which is stored in List at given Index.

这会将序列呈现为存储在给定索引的 List 中的字母表。