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


##########
nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/main/java/org/apache/nifi/processors/excel/SplitExcel.java:
##########
@@ -230,6 +229,32 @@ public void onTrigger(ProcessContext context, 
ProcessSession session) throws Pro
         session.transfer(flowFileSplits, REL_SPLIT);
     }
 
-    private record WorkbookSplit(int index, FlowFile content, String 
sheetName, int numRows) {
+    private int copyRows(final Sheet originalSheet, final SXSSFSheet 
destinationSheet) {
+        final CellCopyContext cellCopyContext = new CellCopyContext();
+        int rowCount = 0;
+
+        for (final 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;

Review Comment:
   Is there a reason for the prefixed `++` as opposed to the suffix approach?
   ```suggestion
               rowCount++;
   ```



##########
nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/main/java/org/apache/nifi/processors/excel/SplitExcel.java:
##########
@@ -125,9 +131,9 @@ public class SplitExcel extends AbstractProcessor {
             .cellStyle(CellCopyPolicy.DEFAULT_COPY_CELL_STYLE_POLICY)
             .cellValue(CellCopyPolicy.DEFAULT_COPY_CELL_VALUE_POLICY)
             .condenseRows(CellCopyPolicy.DEFAULT_CONDENSE_ROWS_POLICY)
-            .copyHyperlink(CellCopyPolicy.DEFAULT_COPY_HYPERLINK_POLICY)
+            .copyHyperlink(false) // NOTE: the hyperlinks appear at end of 
sheet, so we need to iterate them separately at the end.

Review Comment:
   What does the comment mean that hyperlinks appear "at the end of the sheet"?



##########
nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/test/java/org/apache/nifi/processors/excel/TestSplitExcel.java:
##########
@@ -239,6 +241,38 @@ void testCopyDateTime() throws Exception {
         }
     }
 
+    @Test
+    void testHyperlinks() throws IOException {
+        final Path hyperlinksFile = 
Paths.get("src/test/resources/excel/hyperlinks.xlsx");
+        runner.enqueue(hyperlinksFile);
+
+        runner.run();
+
+        runner.assertTransferCount(SplitExcel.REL_SPLIT, 1);
+        runner.assertTransferCount(SplitExcel.REL_ORIGINAL, 1);
+        runner.assertTransferCount(SplitExcel.REL_FAILURE, 0);
+
+        final MockFlowFile flowFile = 
runner.getFlowFilesForRelationship(SplitExcel.REL_SPLIT).getFirst();
+        try (XSSFWorkbook workbook = new 
XSSFWorkbook(flowFile.getContentStream())) {
+            final Sheet sheet = workbook.getSheetAt(0);
+            assertEquals("Sheet1", sheet.getSheetName());
+
+            final List<XSSFHyperlink> hyperlinks = (List<XSSFHyperlink>) 
sheet.getHyperlinkList();
+            Assertions.assertIterableEquals(

Review Comment:
   The `import static` approach should be used instead of `Assertions`:
   ```suggestion
               assertIterableEquals(
   ```



-- 
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