</devs>
<release version="3.0.2-FINAL" date="2007-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">43093 - [PATCH] - Fix formula evaluator support for Area3D references to other sheets</action>
<action dev="POI-DEVELOPERS" type="fix">Improvements to HSSFDateUtils.isADateFormat, and have HSSFDateUtil.isCellDateFormatted use this</action>
<action dev="POI-DEVELOPERS" type="fix">42999 - [PATCH] - Fix for HSSFPatriarch positioning problems</action>
<action dev="POI-DEVELOPERS" type="add">Support for write-protecting a HSSF workbook</action>
<changes>
<release version="3.0.2-FINAL" date="2007-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">43093 - [PATCH] - Fix formula evaluator support for Area3D references to other sheets</action>
<action dev="POI-DEVELOPERS" type="fix">Improvements to HSSFDateUtils.isADateFormat, and have HSSFDateUtil.isCellDateFormatted use this</action>
<action dev="POI-DEVELOPERS" type="fix">42999 - [PATCH] - Fix for HSSFPatriarch positioning problems</action>
<action dev="POI-DEVELOPERS" type="add">Support for write-protecting a HSSF workbook</action>
import org.apache.poi.hssf.record.formula.eval.UnaryMinusEval;
import org.apache.poi.hssf.record.formula.eval.UnaryPlusEval;
import org.apache.poi.hssf.record.formula.eval.ValueEval;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
/**
* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
short col0 = a3dp.getFirstColumn();
short row1 = a3dp.getLastRow();
short col1 = a3dp.getLastColumn();
- HSSFSheet xsheet = workbook.getSheetAt(a3dp.getExternSheetIndex());
+ Workbook wb = workbook.getWorkbook();
+ HSSFSheet xsheet = workbook.getSheetAt(wb.getSheetIndexFromExternSheetIndex(a3dp.getExternSheetIndex()));
ValueEval[] values = new ValueEval[(row1 - row0 + 1) * (col1 - col0 + 1)];
- for (short x = row0; sheet != null && x < row1 + 1; x++) {
- HSSFRow row = sheet.getRow(x);
+ for (short x = row0; xsheet != null && x < row1 + 1; x++) {
+ HSSFRow row = xsheet.getRow(x);
for (short y = col0; row != null && y < col1 + 1; y++) {
values[(x - row0) * (col1 - col0 + 1) + (y - col0)] =
getEvalForCell(row.getCell(y), row, xsheet, workbook);
--- /dev/null
+package org.apache.poi.hssf.usermodel;
+
+import junit.framework.TestCase;
+
+public class TestBug43093 extends TestCase {
+
+ private static void addNewSheetWithCellsA1toD4(HSSFWorkbook book, int sheet) {
+
+ HSSFSheet sht = book .createSheet("s" + sheet);
+ for (short r=0; r < 4; r++) {
+
+ HSSFRow row = sht.createRow (r);
+ for (short c=0; c < 4; c++) {
+
+ HSSFCell cel = row.createCell(c);
+ /**/ cel.setCellValue(sheet*100 + r*10 + c);
+ }
+ }
+ }
+
+ public void testBug43093() throws Exception {
+ HSSFWorkbook xlw = new HSSFWorkbook();
+
+ addNewSheetWithCellsA1toD4(xlw, 1);
+ addNewSheetWithCellsA1toD4(xlw, 2);
+ addNewSheetWithCellsA1toD4(xlw, 3);
+ addNewSheetWithCellsA1toD4(xlw, 4);
+
+ HSSFSheet s2 = xlw.getSheet("s2");
+ HSSFRow s2r3 = s2.getRow(3);
+ HSSFCell s2E4 = s2r3.createCell((short)4);
+ /**/ s2E4.setCellFormula("SUM(s3!B2:C3)");
+
+ HSSFFormulaEvaluator eva = new HSSFFormulaEvaluator(s2, xlw);
+ eva.setCurrentRow(s2r3);
+ double d = eva.evaluate(s2E4).getNumberValue();
+
+ // internalEvaluate(...) Area3DEval.: 311+312+321+322 expected
+ assertEquals(d, (double)(311+312+321+322), 0.0000001);
+ // System.out.println("Area3DEval ok.: 311+312+321+322=" + d);
+ }
+}