我有一张带键和值的地图 键为“日期” 价值为“豆”。
假设我有bean作为
public class example{
private long id;
private String name;
private long date;
private String workAssigned;
//getters & setters
}
I got a list of bean values.
List<example> list = getDetails();
i am iterating and forming a map .
as
for(example e : list)
{
List<example> list=exampleMap.get(example.getDate());
if(list==null){
list = new ArrayList<example>();
exampleMap.put(example.getDate(), list);
}
list.add(e);
}
Now i got a map with date..
Excel代码
int rows = 5;
for (Map.Entry<String, List<example>> entry:exampleMap.entrySet() ) {
String date=entry.getKey();
excelSheet.mergeCells(0, rows, 4, rows);
addLabel(excelSheet, maxcolumn, rows, date, timesLeftDate);
rows++;
List<example> DataLists=entry.getValue();
for (example DataList : DataLists) {
excelSheet.mergeCells(maxcolumn, rows, maxcolumn+1, rows);
excelSheet.mergeCells(maxcolumn+2, rows, maxcolumn+3, rows);
addLabel(excelSheet, maxcolumn, rows, DataList.getName, timesLeft);
addLabel(excelSheet, maxcolumn+2, rows, DataList.getId(), timesCenter);
addLabel(excelSheet, maxcolumn+4, rows, DataList.getWorkAssigned(), timesCenter);
rows++;
}
rows++;
}
现在我需要将这些值写入xls .. 我已经完成但我正在垂直地像
Employee1 Id workAssigned
2016-04-15
bhavani 12345651 read
Julian Thomak 46546546 write
Shiva 54464646 read
2016-04-20
Bhavani 5479844 write
Shiva 4745654 read
But expected output:
---------------------------------------------------------
2016-04-15 2016-04-16
--------------------------------------------------------
Employee1 Id workAssigned id workassgigned
-------------------------------------------------------
bhavani 12345651 read 5479844 write
Julian Thomak 46546546 write
Shiva 54464646 read 4745654 read
sahu 1024158 read
希望你低调..任何人都可以帮我解决这个问题。