dan-s1 commented on code in PR #9874:
URL: https://github.com/apache/nifi/pull/9874#discussion_r2052629031


##########
nifi-extension-bundles/nifi-poi-bundle/nifi-poi-services/src/main/java/org/apache/nifi/excel/RowIterator.java:
##########
@@ -129,4 +151,37 @@ private boolean hasExhaustedRows() {
         }
         return exhausted;
     }
+
+    private boolean isXSSFExcelFile(InputStream in, final String password) {
+        final FileMagic fileType;
+        try {
+            fileType = FileMagic.valueOf(in);
+        } catch (final IOException e) {
+            throw new ProcessException("Failed to determine file type", e);
+        }
+
+        if (fileType == FileMagic.OOXML) {
+            // Unencrypted XLSX file
+            return true;
+        }
+        if (fileType != FileMagic.OLE2) {
+            // Not an Excel file
+            return false;
+        }
+        if (password == null) {
+            // If there is no password on the OLE2 file, then it's an XLS 
file. Otherwise, the type must be further
+            // investigated.
+            return false;
+        }
+
+        DirectoryNode root;
+        try {
+            root = new POIFSFileSystem(new 
NonCloseableInputStream(in)).getRoot();
+            in.reset();

Review Comment:
   @exceptionfactory Just want to clarify since `reset` can also throw an 
`IOException` the `finally` would have to also have a try catch block.



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