Author: amol
Date: Wed Nov 22 15:12:06 2006
New Revision: 478367

URL: http://svn.apache.org/viewvc?view=rev&rev=478367
Log:
Fixed: 
1. evaluateInCell failed if the cell originally contained a numeric value
2. Sheet references were not handled correctly

Modified:
    
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java

Modified: 
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
URL: 
http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java?view=diff&rev=478367&r1=478366&r2=478367
==============================================================================
--- 
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
 (original)
+++ 
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
 Wed Nov 22 15:12:06 2006
@@ -10,6 +10,7 @@
 import java.util.Stack;
 
 import org.apache.poi.hssf.model.FormulaParser;
+import org.apache.poi.hssf.model.Workbook;
 import org.apache.poi.hssf.record.formula.AddPtg;
 import org.apache.poi.hssf.record.formula.Area3DPtg;
 import org.apache.poi.hssf.record.formula.AreaPtg;
@@ -100,11 +101,9 @@
     private static final Map OPERATION_EVALS_MAP = new HashMap();
 
     /*
-     * If you dont like this map, join the club :) I did this becoz it was
-     * desired to keep the FormulaEvaluator separate from FormulaParser and
-     * related classes in the CVS-HEAD. So now we need some mapping between the
-     * Ptg tokens that the FormulaParser returns and the *Eval classes taht are
-     * used by the FormulaEvaluator - hence the following :)
+     * Following is the mapping between the Ptg tokens returned 
+     * by the FormulaParser and the *Eval classes that are used 
+     * by the FormulaEvaluator
      */
     static {
         VALUE_EVALS_MAP.put(BoolPtg.class, BoolEval.class);
@@ -214,6 +213,7 @@
                     cell.setCellValue(cv.getErrorValue());
                     break;
                 case HSSFCell.CELL_TYPE_NUMERIC:
+                       cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                     cell.setCellValue(cv.getNumberValue());
                     break;
                 case HSSFCell.CELL_TYPE_STRING:
@@ -326,8 +326,9 @@
                 Ref3DPtg ptg = (Ref3DPtg) ptgs[i];
                 short colnum = ptg.getColumn();
                 short rownum = ptg.getRow();
-                HSSFSheet xsheet = 
workbook.getSheetAt(ptg.getExternSheetIndex());
-                HSSFRow row = sheet.getRow(rownum);
+                Workbook wb = workbook.getWorkbook();
+                HSSFSheet xsheet = 
workbook.getSheetAt(wb.getSheetIndexFromExternSheetIndex(ptg.getExternSheetIndex()));
+                HSSFRow row = xsheet.getRow(rownum);
                 HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
                 pushRef3DEval(ptg, stack, cell, row, xsheet, workbook);
             }



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

Reply via email to