Bug Description: Set the formula like this: cell.setCellType(HSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("NotExcelFormula(A1,A2)"); This formula displays in the Excel is wrong: =A1(A2)NOTEXCELFORMULA The method FormulaParser.function() put a NamePtg at the end of the function tokens, however the NamePtg must be the first of the tokens. I have fixed the method "FormulaParser.function()" as the following: FormulaParser.function(String name){ //average 2 args per function this.functionTokens.add(0, new ArrayList(2)); short funcIndex = AbstractFunctionPtg.lookupIndex(name); //NamePtg at the first if (funcIndex == AbstractFunctionPtg.INDEX_EXTERNAL) { tokens.add(new NamePtg(name, this.book)); } Match('('); int numArgs = Arguments(); Match(')'); //argument number must be plus 1 if (funcIndex == AbstractFunctionPtg.INDEX_EXTERNAL) { numArgs++; } AbstractFunctionPtg functionPtg = getFunction(name,(byte)numArgs); tokens.add(functionPtg); // if (functionPtg.getName().equals("externalflag")) { // tokens.add(new NamePtg(name, this.book)); // } //remove what we just put in this.functionTokens.remove(0); }
Retested in OK 3.1-beta1. This was probably fixed in bug 44504 (svn r633547)