avik 2002/06/12 05:40:03
Modified: src/java/org/apache/poi/hssf/dev FormulaViewer.java
src/java/org/apache/poi/hssf/record/formula
AbstractFunctionPtg.java FormulaParser.java
src/testcases/org/apache/poi/hssf/usermodel
TestFormulas.java
Log:
fix for bug 9802, we write simple sum ptg, tho we can also read attr ptg. trying to
write an attr ptg messes up the class change algo.
Revision Changes Path
1.4 +1 -0 jakarta-poi/src/java/org/apache/poi/hssf/dev/FormulaViewer.java
Index: FormulaViewer.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/dev/FormulaViewer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FormulaViewer.java 11 Jun 2002 20:18:28 -0000 1.3
+++ FormulaViewer.java 12 Jun 2002 12:40:03 -0000 1.4
@@ -142,6 +142,7 @@
StringBuffer buf = new StringBuffer();
+ if (token instanceof ExpPtg) return;
buf.append(name=((OperationPtg) token).toFormulaString());
buf.append(sep);
switch (token.getPtgClass()) {
1.2 +1 -1
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
Index: AbstractFunctionPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractFunctionPtg.java 11 Jun 2002 20:18:28 -0000 1.1
+++ AbstractFunctionPtg.java 12 Jun 2002 12:40:03 -0000 1.2
@@ -446,7 +446,7 @@
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);
1.21 +4 -4
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java
Index: FormulaParser.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FormulaParser.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- FormulaParser.java 11 Jun 2002 20:18:28 -0000 1.20
+++ FormulaParser.java 12 Jun 2002 12:40:03 -0000 1.21
@@ -264,17 +264,17 @@
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 */
1.19 +6 -0
jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
Index: TestFormulas.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- TestFormulas.java 11 Jun 2002 20:20:41 -0000 1.18
+++ TestFormulas.java 12 Jun 2002 12:40:03 -0000 1.19
@@ -775,6 +775,12 @@
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);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>