From 176a685e2d92f6cd6fea7d371d71b0facafc39b5 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 24 Oct 2023 09:34:58 +0000 Subject: [PATCH] [bug-67778] add more null checks to BaseXSSFFormulaEvaluator git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1913258 13f79535-47bb-0310-9956-ffa450edef68 --- .../usermodel/BaseXSSFFormulaEvaluator.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java index 50e241fddb..3145e3f43c 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java @@ -143,13 +143,18 @@ public abstract class BaseXSSFFormulaEvaluator extends BaseFormulaEvaluator { int lastRow = area3DPxg.getLastRow(); for (int rowIndex = firstRow; rowIndex <= lastRow; rowIndex++) { XSSFRow row = sheet.getRow(rowIndex); - int firstColumn = area3DPxg.getFirstColumn(); - int lastColumn = area3DPxg.getLastColumn(); - for (int cellIndex = firstColumn; cellIndex <= lastColumn; cellIndex++) { - XSSFCell cell = row.getCell(cellIndex); - String cellValue = cell.getRawValue(); - String cellR = new CellReference(cell).formatAsString(false); - externalLinksTable.cacheData(sheet.getSheetName(), (long)rowIndex + 1, cellR, cellValue); + if (row != null) { + int firstColumn = area3DPxg.getFirstColumn(); + int lastColumn = area3DPxg.getLastColumn(); + for (int cellIndex = firstColumn; cellIndex <= lastColumn; cellIndex++) { + XSSFCell cell = row.getCell(cellIndex); + if (cell != null) { + String cellValue = cell.getRawValue(); + String cellR = new CellReference(cell).formatAsString(false); + externalLinksTable.cacheData(sheet.getSheetName(), + (long)rowIndex + 1, cellR, cellValue); + } + } } } }