diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2021-10-18 17:40:47 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2021-10-18 17:40:47 +0000 |
commit | 611f5273fdc6a2105a3239fc337b6500af6026ba (patch) | |
tree | a39407d3011cf4fdac1ff6da8a718bb0fbdb03e4 /poi-examples/src | |
parent | 787af858e72b0c60ea8b89d47fed230c5582fb62 (diff) | |
download | poi-611f5273fdc6a2105a3239fc337b6500af6026ba.tar.gz poi-611f5273fdc6a2105a3239fc337b6500af6026ba.zip |
sonar fixes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894360 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-examples/src')
-rw-r--r-- | poi-examples/src/main/java/org/apache/poi/examples/ss/CellStyleDetails.java | 4 | ||||
-rw-r--r-- | poi-examples/src/main/java/org/apache/poi/examples/ss/formula/UserDefinedFunctionExample.java | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/ss/CellStyleDetails.java b/poi-examples/src/main/java/org/apache/poi/examples/ss/CellStyleDetails.java index 6997a9e8fa..ce69271805 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/ss/CellStyleDetails.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/ss/CellStyleDetails.java @@ -47,6 +47,10 @@ public final class CellStyleDetails { } try (Workbook wb = WorkbookFactory.create(new File(args[0]))) { + if (wb == null) { + System.out.println("Workbook "+args[0]+" can't be loaded."); + return; + } DataFormatter formatter = new DataFormatter(); for (int sn = 0; sn < wb.getNumberOfSheets(); sn++) { diff --git a/poi-examples/src/main/java/org/apache/poi/examples/ss/formula/UserDefinedFunctionExample.java b/poi-examples/src/main/java/org/apache/poi/examples/ss/formula/UserDefinedFunctionExample.java index 939fd9ab9d..be03faebbb 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/ss/formula/UserDefinedFunctionExample.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/ss/formula/UserDefinedFunctionExample.java @@ -54,6 +54,10 @@ public final class UserDefinedFunctionExample { File workbookFile = new File( args[0] ) ; try (Workbook workbook = WorkbookFactory.create(workbookFile, null, true)) { + if (workbook == null) { + System.out.println("Workbook "+workbookFile+" can't be loaded."); + return; + } String[] functionNames = {"calculatePayment"}; FreeRefFunction[] functionImpls = {new CalculateMortgage()}; |