Update the CheckFunctionsSupported example to take advantage of the new NotImplementedFunctionException to identify the function that is missing

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1607589 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2014-07-03 11:21:03 +00:00
parent 3105bd6f18
commit 4c8504965f
1 changed files with 9 additions and 4 deletions

View File

@ -27,6 +27,7 @@ import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import org.apache.poi.ss.formula.eval.NotImplementedException; import org.apache.poi.ss.formula.eval.NotImplementedException;
import org.apache.poi.ss.formula.eval.NotImplementedFunctionException;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
@ -128,10 +129,14 @@ public class CheckFunctionsSupported {
try { try {
evaluator.evaluate(c); evaluator.evaluate(c);
} catch (Exception e) { } catch (Exception e) {
if (e instanceof NotImplementedException) { if (e instanceof NotImplementedException && e.getCause() != null) {
NotImplementedException nie = (NotImplementedException)e; // Has been wrapped with cell details, but we know those
// TODO e = (Exception)e.getCause();
System.err.println("TODO - Not Implemented: " + nie); }
if (e instanceof NotImplementedFunctionException) {
NotImplementedFunctionException nie = (NotImplementedFunctionException)e;
unsupportedFunctions.add(nie.getFunctionName());
} }
unevaluatableCells.put(new CellReference(c), e); unevaluatableCells.put(new CellReference(c), e);
} }