【发布时间】:2016-11-29 09:18:19
【问题描述】:
DynamicJasper 中 Hashmap 属性的动态列。有可能吗?
您好,我是 Dynamic Jasper 的新手。我在处理一些应该来自 Hashmap 属性的列时遇到了一些问题。我举个例子更清楚:
class Product {
private String name;
private String price;
private String whatever;
private Hashmap<String,String> comments;
}
我的数据源是List<Product> 的产品;
|__name___|___price___|_____whatever_____|______First item inside the comments list_____|___Second item inside the comments list____|___N item inside the comments list __|
列的名称将与 hashmap 中的 key 相同。value 是 hashmap 的值。 每个对象(产品)都有一个带有不同 cmets(值)但键相同的 hashmap。例如:
product1: name1,price1, hashmap: ("quality","good")("easyToUse","yes")
product2: name2,price2, hashmap: ("quality","bad")("easyToUse","no")
报告应该是这样的:
|__ name_______|______price _____|_____quality_____|______easyToUse______|
|___name1_____|______price1_____|______ good_____|______ yes___________|
|___name2_____|______price2_____|______ bad______|______ no____________|
有可能还是我应该尝试另一种方法? 如何动态创建列?并设置正确的值?
最好的问候
【问题讨论】:
-
列是什么意思??你试过任何代码吗?
-
你的意思是
toString方法,你首先打印名称、值等,然后是 cmets 列表? -
@RimonMostafiz 我发现了这个:dynamicreports.org/forum/viewtopic.php?f=1&t=170 但我无法使用它。 =(
-
@aimee no。每个产品对象都有一个哈希图。键是列名,值是列的值。
标签: java dynamic-jasper