]> source.dussan.org Git - poi.git/commitdiff
fix for bug 9802, we write simple sum ptg, tho we can also read attr ptg. trying...
authorAvik Sengupta <avik@apache.org>
Wed, 12 Jun 2002 12:40:03 +0000 (12:40 +0000)
committerAvik Sengupta <avik@apache.org>
Wed, 12 Jun 2002 12:40:03 +0000 (12:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352687 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/dev/FormulaViewer.java
src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
src/java/org/apache/poi/hssf/record/formula/FormulaParser.java
src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java

index 30e26838064d217f74ba9cff53dde6b468f268c1..879f8949974da59109b7b759b0cfbfd24cf7cdaa 100644 (file)
@@ -142,6 +142,7 @@ public class FormulaViewer
             
             StringBuffer buf = new StringBuffer();
             
+            if (token instanceof ExpPtg) return;
             buf.append(name=((OperationPtg) token).toFormulaString());
             buf.append(sep);
             switch (token.getPtgClass()) {
index 50c76fdaf3b9dbeb99cbaf12e313f258c6647209..509d4156decde288ca767ffa8299d1c8cda982f5 100644 (file)
@@ -446,7 +446,7 @@ public abstract class AbstractFunctionPtg extends OperationPtg {
 functionData[0][0]=new Byte(Ptg.CLASS_VALUE);functionData[0][1]=new byte[] {Ptg.CLASS_REF};functionData[0][2]=new Integer(-1);
 functionData[2][0]=new Byte(Ptg.CLASS_VALUE);functionData[2][1]=new byte[] {Ptg.CLASS_VALUE};functionData[2][2]=new Integer(1);
 functionData[3][0]=new Byte(Ptg.CLASS_VALUE);functionData[3][1]=new byte[] {Ptg.CLASS_VALUE};functionData[3][2]=new Integer(1);
-functionData[4][0]=new Byte(Ptg.CLASS_REF);functionData[4][1]=new byte[] {Ptg.CLASS_REF};functionData[4][2]=new Integer(-1);
+functionData[4][0]=new Byte(Ptg.CLASS_VALUE);functionData[4][1]=new byte[] {Ptg.CLASS_REF};functionData[4][2]=new Integer(-1);
 functionData[5][0]=new Byte(Ptg.CLASS_VALUE);functionData[5][1]=new byte[] {Ptg.CLASS_REF};functionData[5][2]=new Integer(-1);
 functionData[6][0]=new Byte(Ptg.CLASS_VALUE);functionData[6][1]=new byte[] {Ptg.CLASS_REF};functionData[6][2]=new Integer(-1);
 functionData[7][0]=new Byte(Ptg.CLASS_VALUE);functionData[7][1]=new byte[] {Ptg.CLASS_REF};functionData[7][2]=new Integer(-1);
index cc7490aefd00faedec7735405e0a496f851c0331..a07199f19dc0b2194dd6063407f285891b7d772c 100644 (file)
@@ -264,17 +264,17 @@ public class FormulaParser {
     
     private Ptg function(String name,byte numArgs) {
         Ptg retval = null;
-        
-        if (numArgs == 1 && name.equals("SUM")) {
+        retval = new FuncVarPtg(name,numArgs);
+       /** if (numArgs == 1 && name.equals("SUM")) {
             AttrPtg ptg = new AttrPtg();
             ptg.setData((short)1); //sums don't care but this is what excel does.
             ptg.setSum(true);
             retval = ptg;
         } else {
             retval = new FuncVarPtg(name,numArgs);
-        }
+        }*/
         
-        return retval;
+        return retval; 
     }
     
     /** get arguments to a function */
index bbb5194f372a9113e27007076d1970c42a0e0cd2..e3e17fa7e808387b3064c3217475346754c24cb9 100644 (file)
@@ -775,6 +775,12 @@ extends TestCase {
             c=r.createCell( (short) 5);
             c.setCellFormula("SIN(A2)");
             
+            c=r.createCell( (short) 6);
+            c.setCellFormula("SUM(A2:A3)");
+            
+            c=r.createCell( (short) 7);
+            c.setCellFormula("SUM(A2,A3)");
+            
             r = s.createRow((short) 1);c=r.createCell( (short) 0); c.setCellValue(2.0);
              r = s.createRow((short) 2);c=r.createCell( (short) 0); c.setCellValue(3.0);