You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2006/04/20 15:45:00 UTC

DO NOT REPLY [Bug 39365] New: - Can not set a formula which is not a excel to HSSF

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39365>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39365

           Summary: Can not set a formula which is not a excel to HSSF
           Product: POI
           Version: 2.5
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: xxpitch@21cn.com


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); 
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/