Created attachment 24614 [details] Fix. There is simple example when we set wrong formula and get FormulaParseException. public class Test { public static void main(String[] args) throws Exception{ HSSFWorkbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet(); Row row = sheet.createRow(0); Cell cell = row.createCell(0); cell.setCellFormula("Sasd(1)"); } } But we cant catch it because its visibility is package. We can't catch this exception outside the POI internal. Visibility is raised in patch.
There's a comment on the exception: // This class was given package scope until it would become clear that it is useful to // general client code. Probably one for Josh to comment on?
Created attachment 24621 [details] Revised patch making FormulaParseException a public top-level type I originally added this exception quite some time back in the patch of bug 44504. The purpose of the exception is to tell the difference between internal POI errors and parsing errors caused by a bad user-supplied formula. I deliberately restricted visibility for two reasons - firstly because I didn't want to augment POI's public API and secondly because I wasn't confident that the formula parser did a good job of recognising formula errors yet. Having said that, I think the formula parser has improved greatly since then (almost thirty bugs fixed and more than a dozen additional enhancements) so it is probably more reliable in throwing FormulaParseException correctly now. As far as the API is concerned, I'd like to make this class a top level class perhaps: org.apache.poi.ss.formula.FormulaParseException It should be OK to make this change since no-one has been able to specifically catch this exception so far. I see in your patch you left the the exception unchecked (which I agree with). I'm also considering declaring this exception on Cell.setCellFormula() for clarity. It's slightly unusual to have declared unchecked exceptions but that seems like the best approach here. The attached patch file includes the changes described here and some related clean-up. Let me know if you think it needs further changes. Otherwise I'll apply it over the weekend.
Your patch completely resolves the problem. Thanks.
Applied in svn r885007.