Bug 39365 - Can not set a formula which is not a excel to HSSF
Summary: Can not set a formula which is not a excel to HSSF
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-20 13:44 UTC by Allen Hoo
Modified: 2008-05-10 17:42 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Allen Hoo 2006-04-20 13:44:59 UTC
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); 
}
Comment 1 Josh Micich 2008-05-10 17:42:52 UTC
Retested in OK 3.1-beta1.

This was probably fixed in bug 44504 (svn r633547)