I have an excel template with two sheets that I want to populate through XLSTransformer
. The data are different for the two sheets (list of different lenghts, with one taking results of a table - see code below), meaning that I cannot pass them through one map.
I've tried with two maps :
//for the first excel sheet
Map<String, List<ListData>> beanParams = new HashMap<String, List<ListData>>();
beanParams.put("rs", rs);
//for the second one
Map<String, List<DetailResult>> beanParams2 = new HashMap<String, List<DetailResult>>();
beanParams2.put("detRes", detRes);
XLSTransformer former = new XLSTransformer();
former.transformXLS(srcFilePath, beanParams, destFilePath);
former.transformXLS(srcFilePath, beanParams2, destFilePath);
The lists look like this :
List<Results> rs = new ArrayList<Results>();
Results s1 = new Results(compteurFemme, compteurHomme, compteurTot, averageTempsFemme, averageTempsHomme, averageTempsTot);
rs.add(s1);
List<ResultsDetails> detRes = new ArrayList<ResultsDetails>();
for(int i=0; i<tableau.getRowCount(); i++){
ResultsDetails newRes = new ResultsDetails(item[i], rep[i], justefaux[i], tempsrep[i]);
item[i]=((DataIdGenre) tableau.getModel()).getValueAt(i, 2).toString();
rep[i]=((DataIdGenre) tableau.getModel()).getValueAt(i, 3).toString();
justefaux[i]=((DataIdGenre) tableau.getModel()).getValueAt(i, 4).toString();
tempsrep[i]=((DataIdGenre) tableau.getModel()).getValueAt(i, 5).toString();
detRes.add(newRes);
}
Individually, the two exports are working on the respective sheet, but together, the second erases the first one.
I then try to use some kind of multimap, with one key (the one I put in excel) for two values
Map<String, List<Object>> hm = new HashMap<String, List<Object>>();
List<Object> values = new ArrayList<Object>();
values.add(rs);
values.add(detRes);
hm.put("det", values);
XLSTransformer former = new XLSTransformer();
former.transformXLS(srcFilePath, hm, destFilePath);
But I got an error telling me that the datas were inaccessible.
So my question is, is there a way to deal directly with different sheets when using XLSTransformer
?