Summary: | Not existing external links cause crash | ||
---|---|---|---|
Product: | POI | Reporter: | Vasili <gavr145> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED INVALID | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 3.7-dev | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Attachments: | patch screens the exceptions thrown due to errors during evaluation of forumas |
Description
Vasili
2010-05-06 10:44:33 UTC
If you don't have the external files, you can't calculate the formulas So, either don't explicitly trigger the calculation of the formulas (use the cached values instead), or get the files to hand before you trigger the evaluation (In reply to comment #1) > If you don't have the external files, you can't calculate the formulas > > So, either don't explicitly trigger the calculation of the formulas (use the > cached values instead), or get the files to hand before you trigger the > evaluation I understand the 1st. But we have no control on what users may leave (they may leave references). JXL code processes such 2003 spreadsheets, POI crashes, with the same approach. Isn't it easier - to put try/catch in POI code or to test File.exists(), treating the links as not existing? The problem that the references are resolved inside POI code and our code just evaluates formulas - when it is a formula, calling formulaEvaluator.evaluate()- when formula is found (so has no knowledge that it is a file/reference at all. And the path to the file is resolved inside POI). As I believe - the check File.exists or try/catch and compatibility with the old code (which is still in production) will be only beneficial. so, please consider this as a request for a very useful (at least for us) feature, which as I suspect - not a big problem to insert (I understand that this is not a bug). Thanks for replying! Regards vasili If you would like to offer a patch, contributions are welcome. A patch would include a unit test that shows throwing the error and catching the error. The feature - "Allow unresolved external references" - would need to be a setting. I'm not sure of the best place, but likely in the FormulaEvaluator interface. Perhaps Josh has an opinion. Created attachment 25410 [details]
patch screens the exceptions thrown due to errors during evaluation of forumas
This patch works for me, making POI behaving like jxl, i.e. ignoring broken links in formulas.
Obviously, you, guys will do it cleaner. I just made a dirty fix for our case, mimicking JXL's behavior, catching all exceptions been caused by incorrect formula evaluation. So, formulas will be evaluated in any case - if formulaEvaluator.setIgnoreFormulaException() was previously invoked. So, the patch does not break backward compatibility. Oh, sorry, I'm not sending unit test (our spreadsheets are too complex, and I do not know Excel good enough - to reproduce the same manually). Auch, I just got failures on my unit tests, so the patch breaks formulas initializer. Not such simple, as always... Please ignore the patch. |