mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
add negative tets
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897827 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7702246209
commit
3feb4ac6cf
@ -207,6 +207,8 @@ public final class OperationEvaluationContext {
|
||||
* @param isA1Style specifies the format for {@code refStrPart1} and {@code refStrPart2}.
|
||||
* Pass {@code true} for 'A1' style and {@code false} for 'R1C1' style.
|
||||
* @return a {@link RefEval} or {@link AreaEval}
|
||||
* @throws IllegalArgumentException
|
||||
* @throws IllegalStateException
|
||||
*/
|
||||
public ValueEval getDynamicReference(String workbookName, String sheetName, String refStrPart1,
|
||||
String refStrPart2, boolean isA1Style) {
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
|
||||
package org.apache.poi.ss.formula.functions;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.poi.ss.formula.FormulaParseException;
|
||||
import org.apache.poi.ss.formula.FormulaParser;
|
||||
import org.apache.poi.ss.formula.FormulaParsingWorkbook;
|
||||
@ -45,6 +47,7 @@ import org.apache.poi.ss.usermodel.Table;
|
||||
*/
|
||||
public final class Indirect implements FreeRefFunction {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(Indirect.class);
|
||||
public static final FreeRefFunction instance = new Indirect();
|
||||
|
||||
private Indirect() {
|
||||
@ -136,7 +139,12 @@ public final class Indirect implements FreeRefFunction {
|
||||
refStrPart1 = refText.substring(0, colonPos).trim();
|
||||
refStrPart2 = refText.substring(colonPos + 1).trim();
|
||||
}
|
||||
return ec.getDynamicReference(workbookName, sheetName, refStrPart1, refStrPart2, isA1style);
|
||||
try {
|
||||
return ec.getDynamicReference(workbookName, sheetName, refStrPart1, refStrPart2, isA1style);
|
||||
} catch (Exception e) {
|
||||
LOGGER.atWarn().log("Indirect function: failed to parse reference {}", text, e);
|
||||
return ErrorEval.REF_INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -109,6 +109,7 @@ public class CellReference implements GenericRecord {
|
||||
/**
|
||||
* Create an cell ref from a string representation. Sheet names containing special characters should be
|
||||
* delimited and escaped as per normal syntax rules for formulas.
|
||||
* @throws IllegalArgumentException if cellRef is not valid
|
||||
*/
|
||||
public CellReference(String cellRef) {
|
||||
if(endsWithIgnoreCase(cellRef, "#REF!")) {
|
||||
|
||||
@ -177,6 +177,7 @@ final class TestIndirect {
|
||||
// simple error propagation:
|
||||
|
||||
confirm(feA, c, "INDIRECT(\"'Sheet1 '!R3C4\", FALSE)", ErrorEval.REF_INVALID);
|
||||
confirm(feA, c, "INDIRECT(\"R2CX\", FALSE)", ErrorEval.REF_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user