summaryrefslogtreecommitdiffstats
path: root/poi-examples
diff options
context:
space:
mode:
Diffstat (limited to 'poi-examples')
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/ss/CellStyleDetails.java4
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/ss/formula/UserDefinedFunctionExample.java4
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()};