diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java index bdadfeb76..b714e44bd 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java @@ -27,6 +27,8 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformService import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException; import org.apache.fineract.infrastructure.core.exception.UnsupportedParameterException; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.CellReference; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellValue; @@ -222,10 +224,26 @@ public class ImportHandlerUtils { } public static CellStyle getCellStyle(Workbook workbook, IndexedColors color) { + CellReference cellReference = new CellReference("A1"); + Sheet predefined = workbook.getSheet(color.toString()); + // if we have already defined this style, return it and don't create another one + if (predefined != null) { + Row row = predefined.getRow(cellReference.getRow()); + Cell cell = row.getCell(cellReference.getCol()); + return cell.getCellStyle(); + } CellStyle style = workbook.createCellStyle(); style.setFillForegroundColor(color.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); + + Sheet cache = workbook.createSheet(color.toString()); + workbook.setSheetHidden(workbook.getSheetIndex(cache), HSSFWorkbook.SHEET_STATE_VERY_HIDDEN); + Row row = cache.createRow(cellReference.getRow()); + Cell cell = row.createCell(cellReference.getCol()); + cell.setCellStyle(style); + return style; + } public static String getDefaultUserMessages(List ApiParameterErrorList){