I Have this method that displays an array of objects in a document.
public File generateODSFileWithTemplate(String fileName, Object[][] lignes, File template) throws FileNotFoundException, IOException, JDOMException, TemplateException {
final Sheet sheet = SpreadSheet.createFromFile(template).getSheet(0);
sheet.setRowCount(lignes.length);
int column = 0;
int row = 0;
//Iterating through the array of Object
for(Object[] rowObj : lignes){
for(Object colObj : rowObj){
sheet.setValueAt(rowObj[column],column,row );
column++;
}
row++;
column = 0;
}
File outFile = new File(fileName);
sheet.getSpreadSheet().saveAs(outFile);
return outFile;
}
Is there a way to use streams instead of for loop?
column incrementcould createeffective finalproblems. Now I'm not saying it's not possible, but there is nothing wrong with the way you are doing it (assuming it achieves the desired result of course).