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
This commit is contained in:
Dominik Stadler 2021-04-26 15:12:26 +00:00
parent 9517445fa9
commit 6b1e23665d
2 changed files with 9 additions and 6 deletions

View File

@ -60,7 +60,7 @@ final class SXSSFEvaluationSheet implements EvaluationSheet {
SXSSFRow row = _xs.getRow(rowIndex); SXSSFRow row = _xs.getRow(rowIndex);
if (row == null) { if (row == null) {
if (rowIndex <= _xs.getLastFlushedRowNum()) { if (rowIndex <= _xs.getLastFlushedRowNum()) {
throw new SXSSFFormulaEvaluator.RowFlushedException(rowIndex); throw new SXSSFFormulaEvaluator.RowFlushedException(rowIndex, _xs.getLastFlushedRowNum());
} }
return null; return null;
} }

View File

@ -112,7 +112,10 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
// Check if any rows have already been flushed out // Check if any rows have already been flushed out
int lastFlushedRowNum = ((SXSSFSheet) sheet).getLastFlushedRowNum(); int lastFlushedRowNum = ((SXSSFSheet) sheet).getLastFlushedRowNum();
if (lastFlushedRowNum > -1) { 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)); 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 { public static class RowFlushedException extends IllegalStateException {
protected RowFlushedException(int rowNum) { protected RowFlushedException(int rowNum, int lastFlushedRowNum) {
super("Row " + rowNum + " has been flushed, cannot evaluate all cells"); super("Row " + rowNum + " has been flushed (rows up to " + lastFlushedRowNum + " have been flushed), cannot evaluate all cells");
} }
} }
} }