fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vorbur...@apache.org
Subject [fineract] branch develop updated: re-use styles so that Excel's 4k row limit isn't exceeded (FINERACT-930)
Date Tue, 05 May 2020 20:30:34 GMT
This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new a855d3a  re-use styles so that Excel's 4k row limit isn't exceeded (FINERACT-930)
a855d3a is described below

commit a855d3a9ccb65ff6107c55401af023e409703df6
Author: Sidney Wasibani <jamesidw@gmail.com>
AuthorDate: Tue May 5 23:30:25 2020 +0300

    re-use styles so that Excel's 4k row limit isn't exceeded (FINERACT-930)
---
 .../bulkimport/importhandler/ImportHandlerUtils.java   | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

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 bdadfeb..b714e44 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<ApiParameterError> ApiParameterErrorList){


Mime
View raw message