exceptionfactory commented on code in PR #10058:
URL: https://github.com/apache/nifi/pull/10058#discussion_r2183269561


##########
nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/main/java/org/apache/nifi/processors/excel/SplitExcel.java:
##########
@@ -127,7 +130,7 @@ public class SplitExcel extends AbstractProcessor {
             .condenseRows(CellCopyPolicy.DEFAULT_CONDENSE_ROWS_POLICY)
             .copyHyperlink(CellCopyPolicy.DEFAULT_COPY_HYPERLINK_POLICY)
             .mergeHyperlink(CellCopyPolicy.DEFAULT_MERGE_HYPERLINK_POLICY)
-            .mergedRegions(CellCopyPolicy.DEFAULT_COPY_MERGED_REGIONS_POLICY)
+            .mergedRegions(false)

Review Comment:
   What is the reason for changing this setting? Is it set to `false` because 
of the explicit merge region handling in the copyRows method?



##########
nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/main/java/org/apache/nifi/processors/excel/SplitExcel.java:
##########
@@ -230,6 +226,29 @@ public void onTrigger(ProcessContext context, 
ProcessSession session) throws Pro
         session.transfer(flowFileSplits, REL_SPLIT);
     }
 
+    public static int copyRows(final Sheet originalSheet, final Sheet 
destinationSheet) {
+        final CellCopyContext cellCopyContext = new CellCopyContext();
+        int rowCount = 0;
+
+        for (Row sourceRow : originalSheet) {
+            final Row destinationRow = 
destinationSheet.createRow(sourceRow.getRowNum());
+            destinationRow.setHeight(sourceRow.getHeight());
+
+            for (final Cell sourceCell : sourceRow) {
+                final Cell destCell = 
destinationRow.createCell(sourceCell.getColumnIndex());
+                CellUtil.copyCell(sourceCell, destCell, CELL_COPY_POLICY, 
cellCopyContext);
+            }
+
+            ++rowCount;
+        }
+
+        for (CellRangeAddress sourceRegion : originalSheet.getMergedRegions()) 
{

Review Comment:
   ```suggestion
           for (final CellRangeAddress sourceRegion : 
originalSheet.getMergedRegions()) {
   ```



##########
nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/main/java/org/apache/nifi/processors/excel/SplitExcel.java:
##########
@@ -167,21 +170,14 @@ public void onTrigger(ProcessContext context, 
ProcessSession session) throws Pro
                 int index = 0;
                 for (final Sheet originalSheet : originalWorkbook) {
                     final String originalSheetName = 
originalSheet.getSheetName();
-                    try (XSSFWorkbook newWorkbook = new XSSFWorkbook()) {
-                        XSSFSheet newSheet = 
newWorkbook.createSheet(originalSheetName);
-                        List<Row> originalRows = new ArrayList<>();
-                        for (Row originalRow : originalSheet) {
-                            originalRows.add(originalRow);
-                        }
-
-                        if (!originalRows.isEmpty()) {
-                            newSheet.copyRows(originalRows, 
originalSheet.getFirstRowNum(), CELL_COPY_POLICY);
-                        }
+                    try (Workbook newWorkbook = new SXSSFWorkbook(null, 
SXSSFWorkbook.DEFAULT_WINDOW_SIZE, false, true)) {
+                        Sheet newSheet = 
newWorkbook.createSheet(originalSheetName);

Review Comment:
   ```suggestion
                           final Sheet newSheet = 
newWorkbook.createSheet(originalSheetName);
   ```



##########
nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/main/java/org/apache/nifi/processors/excel/SplitExcel.java:
##########
@@ -230,6 +226,29 @@ public void onTrigger(ProcessContext context, 
ProcessSession session) throws Pro
         session.transfer(flowFileSplits, REL_SPLIT);
     }
 
+    public static int copyRows(final Sheet originalSheet, final Sheet 
destinationSheet) {

Review Comment:
   This should not be public, and doesn't necessarily need to be static.
   ```suggestion
       private int copyRows(final Sheet originalSheet, final Sheet 
destinationSheet) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to