From 89b2d938dac675ca812426192e0c445e475eb2da Mon Sep 17 00:00:00 2001 From: "Amol S. Deshmukh" Date: Wed, 9 Aug 2006 20:26:40 +0000 Subject: [PATCH] In setCellFormula(String) the Ptg stack in FormulaRecord is cleared before filling it with new values. Prior to this fix, repeated calls to setCellFormula would keep accumulating Ptgs in the stack although only the topmost "size" number of Ptgs would ever be used. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@430137 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hssf/usermodel/HSSFCell.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index c7822c2664..3788a620d4 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -597,8 +597,9 @@ public class HSSFCell } else { setCellType(CELL_TYPE_FORMULA,false,row,col,styleIndex); FormulaRecordAggregate rec = (FormulaRecordAggregate) record; - rec.getFormulaRecord().setOptions(( short ) 2); - rec.getFormulaRecord().setValue(0); + FormulaRecord frec = rec.getFormulaRecord(); + frec.setOptions(( short ) 2); + frec.setValue(0); //only set to default if there is no extended format index already set if (rec.getXFIndex() == (short)0) rec.setXFIndex(( short ) 0x0f); @@ -606,10 +607,16 @@ public class HSSFCell fp.parse(); Ptg[] ptg = fp.getRPNPtg(); int size = 0; - //System.out.println("got Ptgs " + ptg.length); + + // clear the Ptg Stack + for (int i=0, iSize=frec.getNumberOfExpressionTokens(); i