HSSFSheet worksheet = workbook.createSheet(getResourceBundle().getString("MAIN_WORKSHEET"));
if ((objects != null) && !(objects.isEmpty())) {
int lineNumber = 0;
for (Object o : objects) {
Consumption consumpt = (Consumption) o;
// index from 0,0... cell A1 is cell(0,0)
HSSFRow row1 = worksheet.createRow(0);
HSSFCell cellA1 = row1.createCell(0);
cellA1.setCellValue(getResourceBundle().getString("CONSUMPTION_QUANTITY"));
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.GOLD.index);
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellA1.setCellStyle(cellStyle);
HSSFCell cellB1 = row1.createCell(1);
cellB1.setCellValue(getResourceBundle().getString("CONSUMPTION_CATEGORY"));
cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.LIGHT_CORNFLOWER_BLUE.index);
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellB1.setCellStyle(cellStyle);
HSSFCell cellC1 = row1.createCell(2);
cellC1.setCellValue(getResourceBundle().getString("PROGRAM_NAME"));
cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.LIGHT_GREEN.index);
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellC1.setCellStyle(cellStyle);
HSSFCell cellD1 = row1.createCell(3);
cellD1.setCellValue(getResourceBundle().getString("ITEM_DSP5_LICENSE_NUMBER"));
cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.CORAL.index);
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellD1.setCellStyle(cellStyle);
HSSFRow row2 = worksheet.createRow(++lineNumber);
HSSFCell cellA2 = row2.createCell(0);
cellA2.setCellValue(consumpt.getQuantity());
HSSFCell cellB2 = row2.createCell(1);
cellB2.setCellValue(consumpt.getCategory());
HSSFCell cellC2 = row2.createCell(2);
cellC2.setCellValue(consumpt.getProgram().getName());
HSSFCell cellD2 = row2.createCell(3);
cellD2.setCellValue(consumpt.getItem().getDsp5().getLicenseNumber());
lineNumber = lineNumber + 2;
}
}
}