mirror of https://github.com/apache/poi.git
Fixed:
1. evaluateInCell failed if the cell originally contained a numeric value 2. Sheet references were not handled correctly git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@478367 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e191d564b3
commit
5d7b255ef5
|
@ -10,6 +10,7 @@ import java.util.Map;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import org.apache.poi.hssf.model.FormulaParser;
|
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.AddPtg;
|
||||||
import org.apache.poi.hssf.record.formula.Area3DPtg;
|
import org.apache.poi.hssf.record.formula.Area3DPtg;
|
||||||
import org.apache.poi.hssf.record.formula.AreaPtg;
|
import org.apache.poi.hssf.record.formula.AreaPtg;
|
||||||
|
@ -100,11 +101,9 @@ public class HSSFFormulaEvaluator {
|
||||||
private static final Map OPERATION_EVALS_MAP = new HashMap();
|
private static final Map OPERATION_EVALS_MAP = new HashMap();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If you dont like this map, join the club :) I did this becoz it was
|
* Following is the mapping between the Ptg tokens returned
|
||||||
* desired to keep the FormulaEvaluator separate from FormulaParser and
|
* by the FormulaParser and the *Eval classes that are used
|
||||||
* related classes in the CVS-HEAD. So now we need some mapping between the
|
* by the FormulaEvaluator
|
||||||
* Ptg tokens that the FormulaParser returns and the *Eval classes taht are
|
|
||||||
* used by the FormulaEvaluator - hence the following :)
|
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
VALUE_EVALS_MAP.put(BoolPtg.class, BoolEval.class);
|
VALUE_EVALS_MAP.put(BoolPtg.class, BoolEval.class);
|
||||||
|
@ -214,6 +213,7 @@ public class HSSFFormulaEvaluator {
|
||||||
cell.setCellValue(cv.getErrorValue());
|
cell.setCellValue(cv.getErrorValue());
|
||||||
break;
|
break;
|
||||||
case HSSFCell.CELL_TYPE_NUMERIC:
|
case HSSFCell.CELL_TYPE_NUMERIC:
|
||||||
|
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
|
||||||
cell.setCellValue(cv.getNumberValue());
|
cell.setCellValue(cv.getNumberValue());
|
||||||
break;
|
break;
|
||||||
case HSSFCell.CELL_TYPE_STRING:
|
case HSSFCell.CELL_TYPE_STRING:
|
||||||
|
@ -326,8 +326,9 @@ public class HSSFFormulaEvaluator {
|
||||||
Ref3DPtg ptg = (Ref3DPtg) ptgs[i];
|
Ref3DPtg ptg = (Ref3DPtg) ptgs[i];
|
||||||
short colnum = ptg.getColumn();
|
short colnum = ptg.getColumn();
|
||||||
short rownum = ptg.getRow();
|
short rownum = ptg.getRow();
|
||||||
HSSFSheet xsheet = workbook.getSheetAt(ptg.getExternSheetIndex());
|
Workbook wb = workbook.getWorkbook();
|
||||||
HSSFRow row = sheet.getRow(rownum);
|
HSSFSheet xsheet = workbook.getSheetAt(wb.getSheetIndexFromExternSheetIndex(ptg.getExternSheetIndex()));
|
||||||
|
HSSFRow row = xsheet.getRow(rownum);
|
||||||
HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
|
HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
|
||||||
pushRef3DEval(ptg, stack, cell, row, xsheet, workbook);
|
pushRef3DEval(ptg, stack, cell, row, xsheet, workbook);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue