From: Dominik Stadler Date: Mon, 26 Apr 2021 15:12:26 +0000 (+0000) Subject: Improve error message when formulas cannot be evaluated for some rows in SXSSF X-Git-Tag: REL_5_1_0~234 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6b1e23665d413068d0cdb47b97d8f93a467ec0d0;p=poi.git Improve error message when formulas cannot be evaluated for some rows in SXSSF git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1889204 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java index f47b051d24..306b7eeb10 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java @@ -44,7 +44,7 @@ final class SXSSFEvaluationSheet implements EvaluationSheet { public int getLastRowNum() { return _xs.getLastRowNum(); } - + /* (non-Javadoc) * @see org.apache.poi.ss.formula.EvaluationSheet#isRowHidden(int) * @since POI 4.1.0 @@ -60,7 +60,7 @@ final class SXSSFEvaluationSheet implements EvaluationSheet { SXSSFRow row = _xs.getRow(rowIndex); if (row == null) { if (rowIndex <= _xs.getLastFlushedRowNum()) { - throw new SXSSFFormulaEvaluator.RowFlushedException(rowIndex); + throw new SXSSFFormulaEvaluator.RowFlushedException(rowIndex, _xs.getLastFlushedRowNum()); } return null; } @@ -70,7 +70,7 @@ final class SXSSFEvaluationSheet implements EvaluationSheet { } return new SXSSFEvaluationCell(cell, this); } - + /* (non-JavaDoc), inherit JavaDoc from EvaluationSheet * @since POI 3.15 beta 3 */ diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java index 67fe562aac..574dc69dbc 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java @@ -112,7 +112,10 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator { // Check if any rows have already been flushed out int lastFlushedRowNum = ((SXSSFSheet) sheet).getLastFlushedRowNum(); if (lastFlushedRowNum > -1) { - if (! skipOutOfWindow) throw new RowFlushedException(0); + if (!skipOutOfWindow) { + throw new RowFlushedException(0, lastFlushedRowNum); + } + LOG.atInfo().log("Rows up to {} have already been flushed, skipping", box(lastFlushedRowNum)); } } @@ -146,8 +149,8 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator { } } public static class RowFlushedException extends IllegalStateException { - protected RowFlushedException(int rowNum) { - super("Row " + rowNum + " has been flushed, cannot evaluate all cells"); + protected RowFlushedException(int rowNum, int lastFlushedRowNum) { + super("Row " + rowNum + " has been flushed (rows up to " + lastFlushedRowNum + " have been flushed), cannot evaluate all cells"); } } }