public byte[] format(CountResult[] result) {
try {
InputStream in = ExcelFormatter.class.getResourceAsStream("ExcelFormatter.xls");
List<CategoryStepDto> categories = new ArrayList<CategoryStepDto>();
CategoryStepDto nonCategory = new CategoryStepDto();
nonCategory.setCategory("");
boolean useNonCategory = false;
for (CountResult resultDto : result) {
CategoryStepDto categoryDto = null;
if (resultDto.getCategory() == null || "".equals(resultDto.getCategory())) {
categoryDto = nonCategory;
useNonCategory = true;
} else {
categoryDto = getCategoryDto(categories, resultDto.getCategory());
}
categoryDto.setStep(categoryDto.getStep() + resultDto.getStep());
categoryDto.setNone(categoryDto.getNone() + resultDto.getNon());
categoryDto.setComment(categoryDto.getComment() + resultDto.getComment());
}
if (useNonCategory) {
categories.add(nonCategory);
}