diff options
author | Josh Micich <josh@apache.org> | 2009-12-25 23:04:04 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2009-12-25 23:04:04 +0000 |
commit | e9d0f5aeb61fec5d9188b423f52a0de19fbe875d (patch) | |
tree | 1c0a245a1152dafcb3647a0b5b57f3f6d75fbaeb /src/testcases/org | |
parent | 821b4291b232894017da3b34d36d57036d44ed8a (diff) | |
download | poi-e9d0f5aeb61fec5d9188b423f52a0de19fbe875d.tar.gz poi-e9d0f5aeb61fec5d9188b423f52a0de19fbe875d.zip |
Added CellRange return type for Sheet array formula methods. Renamed new test classes to make it clear that array formula evaluation is not being tested yet. Added extra test cases.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@893897 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java | 40 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java | 23 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java | 11 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestHSSFArrayFormulas.java | 60 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java | 122 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java (renamed from src/testcases/org/apache/poi/ss/usermodel/BaseTestArrayFormulas.java) | 112 |
6 files changed, 240 insertions, 128 deletions
diff --git a/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java b/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java index 867bfc35f6..b5b9724c6b 100644 --- a/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java +++ b/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java @@ -45,8 +45,8 @@ public final class TestFormulaRecordAggregate extends TestCase { s.setString("abc"); FormulaRecordAggregate fagg = new FormulaRecordAggregate(f, s, SharedValueManager.createEmpty()); assertEquals("abc", fagg.getStringValue()); - assertFalse(fagg.isPartOfArrayFormula()); - } + assertFalse(fagg.isPartOfArrayFormula()); + } /** * Sometimes a {@link StringRecord} appears after a {@link FormulaRecord} even though the @@ -79,26 +79,26 @@ public final class TestFormulaRecordAggregate extends TestCase { assertEquals(fr, vraRecs[0]); } - public void testArrayFormulas() { - int rownum = 4; - int colnum = 4; + public void testArrayFormulas() { + int rownum = 4; + int colnum = 4; - FormulaRecord fr = new FormulaRecord(); - fr.setRow(rownum); - fr.setColumn((short)colnum); + FormulaRecord fr = new FormulaRecord(); + fr.setRow(rownum); + fr.setColumn((short)colnum); - FormulaRecordAggregate agg = new FormulaRecordAggregate(fr, null, SharedValueManager.createEmpty()); - Ptg[] ptgsForCell = {new ExpPtg(rownum, colnum)}; - agg.setParsedExpression(ptgsForCell); + FormulaRecordAggregate agg = new FormulaRecordAggregate(fr, null, SharedValueManager.createEmpty()); + Ptg[] ptgsForCell = {new ExpPtg(rownum, colnum)}; + agg.setParsedExpression(ptgsForCell); - String formula = "SUM(A1:A3*B1:B3)"; - Ptg[] ptgs = HSSFFormulaParser.parse(formula, null, FormulaType.ARRAY, 0); - agg.setArrayFormula(new CellRangeAddress(rownum, rownum, colnum, colnum), ptgs); + String formula = "SUM(A1:A3*B1:B3)"; + Ptg[] ptgs = HSSFFormulaParser.parse(formula, null, FormulaType.ARRAY, 0); + agg.setArrayFormula(new CellRangeAddress(rownum, rownum, colnum, colnum), ptgs); - assertTrue(agg.isPartOfArrayFormula()); - assertEquals("E5", agg.getArrayFormulaRange().formatAsString()); - Ptg[] ptg = agg.getFormulaTokens(); - String fmlaSer = FormulaRenderer.toFormulaString(null, ptg); - assertEquals(formula, fmlaSer); - } + assertTrue(agg.isPartOfArrayFormula()); + assertEquals("E5", agg.getArrayFormulaRange().formatAsString()); + Ptg[] ptg = agg.getFormulaTokens(); + String fmlaSer = FormulaRenderer.toFormulaString(null, ptg); + assertEquals(formula, fmlaSer); + } } diff --git a/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java b/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java index 66e1c84f03..7e359a3fb1 100644 --- a/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java +++ b/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java @@ -17,6 +17,7 @@ package org.apache.poi.hssf.record.aggregates; +import java.lang.reflect.Field; import java.util.Collection; import java.util.HashMap; @@ -169,4 +170,26 @@ public final class TestSharedValueManager extends TestCase { } assertEquals("$AF24*A$7", formulaText); } + + /** + * Convenience test method for digging the {@link SharedValueManager} out of a + * {@link RowRecordsAggregate}. + */ + public static SharedValueManager extractFromRRA(RowRecordsAggregate rra) { + Field f; + try { + f = RowRecordsAggregate.class.getDeclaredField("_sharedValueManager"); + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } + + f.setAccessible(true); + try { + return (SharedValueManager) f.get(rra); + } catch (IllegalArgumentException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java b/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java index eec05641af..08d35bf6af 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java @@ -22,14 +22,14 @@ import junit.framework.TestSuite; /** * Collects all tests for the <tt>org.apache.poi.hssf.usermodel</tt> package. - * + * * @author Josh Micich */ public class AllUserModelTests { - + public static Test suite() { TestSuite result = new TestSuite(AllUserModelTests.class.getName()); - + result.addTestSuite(TestBugs.class); result.addTestSuite(TestCellStyle.class); result.addTestSuite(TestCloneSheet.class); @@ -57,6 +57,7 @@ public class AllUserModelTests { result.addTestSuite(TestHSSFRichTextString.class); result.addTestSuite(TestHSSFRow.class); result.addTestSuite(TestHSSFSheet.class); + result.addTestSuite(TestHSSFSheetUpdateArrayFormulas.class); result.addTestSuite(TestHSSFTextbox.class); result.addTestSuite(TestHSSFWorkbook.class); result.addTestSuite(TestHSSFName.class); @@ -71,8 +72,8 @@ public class AllUserModelTests { } result.addTestSuite(TestUnicodeWorkbook.class); result.addTestSuite(TestUppercaseWorkbook.class); - result.addTestSuite(TestWorkbook.class); - + result.addTestSuite(TestWorkbook.class); + return result; } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFArrayFormulas.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFArrayFormulas.java deleted file mode 100644 index fb86b0a627..0000000000 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFArrayFormulas.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ - -package org.apache.poi.hssf.usermodel; - -import org.apache.poi.ss.usermodel.BaseTestArrayFormulas; -import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.hssf.HSSFITestDataProvider; -import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate; - -/** - * Test array formulas in HSSF - * - * @author Yegor Kozlov - */ -public final class TestHSSFArrayFormulas extends BaseTestArrayFormulas { - - @Override - protected HSSFITestDataProvider getTestDataProvider(){ - return HSSFITestDataProvider.getInstance(); - } - - public void testHSSFSetArrayFormula_singleCell() { - HSSFWorkbook workbook = getTestDataProvider().createWorkbook(); - HSSFSheet sheet = workbook.createSheet(); - - CellRangeAddress range = new CellRangeAddress(2, 2, 2, 2); - HSSFCell[] cells = sheet.setArrayFormula("SUM(C11:C12*D11:D12)", range); - assertEquals(1, cells.length); - - // sheet.setArrayFormula creates rows and cells for the designated range - assertNotNull(sheet.getRow(2)); - HSSFCell cell = sheet.getRow(2).getCell(2); - assertNotNull(cell); - - assertTrue(cell.isPartOfArrayFormulaGroup()); - //retrieve the range and check it is the same - assertEquals(range.formatAsString(), cell.getArrayFormulaRange().formatAsString()); - - FormulaRecordAggregate agg = (FormulaRecordAggregate)cell.getCellValueRecord(); - assertEquals(range.formatAsString(), agg.getArrayFormulaRange().formatAsString()); - assertTrue(agg.isPartOfArrayFormula()); - - } - -}
\ No newline at end of file diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java new file mode 100644 index 0000000000..625ffdb694 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java @@ -0,0 +1,122 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.hssf.usermodel; + +import junit.framework.AssertionFailedError; + +import org.apache.poi.hssf.HSSFITestDataProvider; +import org.apache.poi.hssf.record.ArrayRecord; +import org.apache.poi.hssf.record.FormulaRecord; +import org.apache.poi.hssf.record.Record; +import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate; +import org.apache.poi.hssf.record.aggregates.RowRecordsAggregate; +import org.apache.poi.hssf.record.aggregates.SharedValueManager; +import org.apache.poi.hssf.record.aggregates.TestSharedValueManager; +import org.apache.poi.ss.usermodel.BaseTestSheetUpdateArrayFormulas; +import org.apache.poi.ss.usermodel.CellRange; +import org.apache.poi.ss.util.CellRangeAddress; + +/** + * Test array formulas in HSSF + * + * @author Yegor Kozlov + * @author Josh Micich + */ +public final class TestHSSFSheetUpdateArrayFormulas extends BaseTestSheetUpdateArrayFormulas { + + public TestHSSFSheetUpdateArrayFormulas() { + super(HSSFITestDataProvider.getInstance()); + } + + // Test methods common with XSSF are in superclass + // Local methods here test HSSF-specific details of updating array formulas + + public void testHSSFSetArrayFormula_singleCell() { + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet sheet = workbook.createSheet("Sheet1"); + + CellRangeAddress range = new CellRangeAddress(2, 2, 2, 2); + HSSFCell[] cells = sheet.setArrayFormula("SUM(C11:C12*D11:D12)", range).getFlattenedCells(); + assertEquals(1, cells.length); + + // sheet.setArrayFormula creates rows and cells for the designated range + assertNotNull(sheet.getRow(2)); + HSSFCell cell = sheet.getRow(2).getCell(2); + assertNotNull(cell); + + assertTrue(cell.isPartOfArrayFormulaGroup()); + //retrieve the range and check it is the same + assertEquals(range.formatAsString(), cell.getArrayFormulaRange().formatAsString()); + + FormulaRecordAggregate agg = (FormulaRecordAggregate)cell.getCellValueRecord(); + assertEquals(range.formatAsString(), agg.getArrayFormulaRange().formatAsString()); + assertTrue(agg.isPartOfArrayFormula()); + } + + /** + * Makes sure the internal state of HSSFSheet is consistent after removing array formulas + */ + public void testAddRemoveArrayFormulas_recordUpdates() { + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet s = wb.createSheet("Sheet1"); + + CellRange<HSSFCell> cr = s.setArrayFormula("123", CellRangeAddress.valueOf("B5:C6")); + Record[] recs; + int ix; + recs = RecordInspector.getRecords(s, 0); + ix = findRecordOfType(recs, ArrayRecord.class, 0); + confirmRecordClass(recs, ix-1, FormulaRecord.class); + confirmRecordClass(recs, ix+1, FormulaRecord.class); + confirmRecordClass(recs, ix+2, FormulaRecord.class); + confirmRecordClass(recs, ix+3, FormulaRecord.class); + // just one array record + assertTrue(findRecordOfType(recs, ArrayRecord.class, ix+1) < 0); + + s.removeArrayFormula(cr.getTopLeftCell()); + + // Make sure the array formula has been removed properly + + recs = RecordInspector.getRecords(s, 0); + assertTrue(findRecordOfType(recs, ArrayRecord.class, 0) < 0); + assertTrue(findRecordOfType(recs, FormulaRecord.class, 0) < 0); + RowRecordsAggregate rra = s.getSheet().getRowsAggregate(); + SharedValueManager svm = TestSharedValueManager.extractFromRRA(rra); + if (svm.getArrayRecord(4, 1) != null) { + throw new AssertionFailedError("Array record was not cleaned up properly."); + } + } + + private static void confirmRecordClass(Record[] recs, int index, Class<? extends Record> cls) { + if (recs.length <= index) { + throw new AssertionFailedError("Expected (" + cls.getName() + ") at index " + + index + " but array length is " + recs.length + "."); + } + assertEquals(cls, recs[index].getClass()); + } + /** + * @return <tt>-1<tt> if not found + */ + private static int findRecordOfType(Record[] recs, Class<?> type, int fromIndex) { + for (int i=fromIndex; i<recs.length; i++) { + if (type.isInstance(recs[i])) { + return i; + } + } + return -1; + } +} diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestArrayFormulas.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java index d07e13b1a4..fdd11fec3a 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestArrayFormulas.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java @@ -17,44 +17,71 @@ package org.apache.poi.ss.usermodel; +import java.util.Arrays; + import junit.framework.TestCase; + import org.apache.poi.ss.ITestDataProvider; -import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.formula.FormulaParseException; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellReference; -import java.util.Iterator; -import java.util.Arrays; - /** - * Common superclass for testing usermodel API for array formulas + * Common superclass for testing usermodel API for array formulas.<br/> + * Formula evaluation is not tested here. * * @author Yegor Kozlov + * @author Josh Micich */ -public abstract class BaseTestArrayFormulas extends TestCase { - - /** - * @return an object that provides test data in HSSF / XSSF specific way - */ - protected abstract ITestDataProvider getTestDataProvider(); +public abstract class BaseTestSheetUpdateArrayFormulas extends TestCase { + protected final ITestDataProvider _testDataProvider; + protected BaseTestSheetUpdateArrayFormulas(ITestDataProvider testDataProvider) { + _testDataProvider = testDataProvider; + } + public final void testAutoCreateOtherCells() { + Workbook workbook = _testDataProvider.createWorkbook(); + Sheet sheet = workbook.createSheet("Sheet1"); + + Row row1 = sheet.createRow(0); + Cell cellA1 = row1.createCell(0); + Cell cellB1 = row1.createCell(1); + String formula = "42"; + sheet.setArrayFormula(formula, CellRangeAddress.valueOf("A1:B2")); + + assertEquals(formula, cellA1.getCellFormula()); + assertEquals(formula, cellB1.getCellFormula()); + Row row2 = sheet.getRow(1); + assertNotNull(row2); + assertEquals(formula, row2.getCell(0).getCellFormula()); + assertEquals(formula, row2.getCell(1).getCellFormula()); + } /** * Set single-cell array formula */ - public void testSetArrayFormula_singleCell() { - Workbook workbook = getTestDataProvider().createWorkbook(); + public final void testSetArrayFormula_singleCell() { + Cell[] cells; + + Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet(); + Cell cell = sheet.createRow(0).createCell(0); + assertFalse(cell.isPartOfArrayFormulaGroup()); + try { + cell.getArrayFormulaRange(); + fail("expected exception"); + } catch (IllegalStateException e){ + assertEquals("Cell A1 is not part of an array formula.", e.getMessage()); + } // row 3 does not yet exist assertNull(sheet.getRow(2)); CellRangeAddress range = new CellRangeAddress(2, 2, 2, 2); - Cell[] cells = sheet.setArrayFormula("SUM(C11:C12*D11:D12)", range); + cells = sheet.setArrayFormula("SUM(C11:C12*D11:D12)", range).getFlattenedCells(); assertEquals(1, cells.length); // sheet.setArrayFormula creates rows and cells for the designated range assertNotNull(sheet.getRow(2)); - Cell cell = sheet.getRow(2).getCell(2); + cell = sheet.getRow(2).getCell(2); assertNotNull(cell); assertTrue(cell.isPartOfArrayFormulaGroup()); @@ -67,8 +94,8 @@ public abstract class BaseTestArrayFormulas extends TestCase { /** * Set multi-cell array formula */ - public void testSetArrayFormula_multiCell() { - Workbook workbook = getTestDataProvider().createWorkbook(); + public final void testSetArrayFormula_multiCell() { + Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet(); // multi-cell formula @@ -77,9 +104,8 @@ public abstract class BaseTestArrayFormulas extends TestCase { assertNull(sheet.getRow(4)); assertNull(sheet.getRow(5)); - CellRangeAddress range = new CellRangeAddress(3, 5, 2, 2); - assertEquals("C4:C6", range.formatAsString()); - Cell[] cells = sheet.setArrayFormula("SUM(A1:A3*B1:B3)", range); + CellRangeAddress range = CellRangeAddress.valueOf("C4:C6"); + Cell[] cells = sheet.setArrayFormula("SUM(A1:A3*B1:B3)", range).getFlattenedCells(); assertEquals(3, cells.length); // sheet.setArrayFormula creates rows and cells for the designated range @@ -100,8 +126,8 @@ public abstract class BaseTestArrayFormulas extends TestCase { * Passing an incorrect formula to sheet.setArrayFormula * should throw FormulaParseException */ - public void testSetArrayFormula_incorrectFormula() { - Workbook workbook = getTestDataProvider().createWorkbook(); + public final void testSetArrayFormula_incorrectFormula() { + Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet(); try { @@ -117,58 +143,58 @@ public abstract class BaseTestArrayFormulas extends TestCase { * Calls of cell.getArrayFormulaRange and sheet.removeArrayFormula * on a not-array-formula cell throw IllegalStateException */ - public void testArrayFormulas_illegalCalls() { - Workbook workbook = getTestDataProvider().createWorkbook(); + public final void testArrayFormulas_illegalCalls() { + Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet(); Cell cell = sheet.createRow(0).createCell(0); assertFalse(cell.isPartOfArrayFormulaGroup()); try { - CellRangeAddress range = cell.getArrayFormulaRange(); + cell.getArrayFormulaRange(); fail("expected exception"); } catch (IllegalStateException e){ - assertEquals("Cell A1 is not part of an array formula", e.getMessage()); + assertEquals("Cell A1 is not part of an array formula.", e.getMessage()); } try { sheet.removeArrayFormula(cell); fail("expected exception"); } catch (IllegalArgumentException e){ - assertEquals("Cell A1 is not part of an array formula", e.getMessage()); + assertEquals("Cell A1 is not part of an array formula.", e.getMessage()); } } /** * create and remove array formulas */ - public void testRemoveArrayFormula() { - Workbook workbook = getTestDataProvider().createWorkbook(); + public final void testRemoveArrayFormula() { + Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet(); CellRangeAddress range = new CellRangeAddress(3, 5, 2, 2); assertEquals("C4:C6", range.formatAsString()); - Cell[] cells = sheet.setArrayFormula("SUM(A1:A3*B1:B3)", range); - assertEquals(3, cells.length); + CellRange<?> cr = sheet.setArrayFormula("SUM(A1:A3*B1:B3)", range); + assertEquals(3, cr.size()); // remove the formula cells in C4:C6 - Cell[] dcells = sheet.removeArrayFormula(cells[0]); + CellRange<?> dcells = sheet.removeArrayFormula(cr.getTopLeftCell()); // removeArrayFormula should return the same cells as setArrayFormula - assertTrue(Arrays.equals(cells, dcells)); + assertTrue(Arrays.equals(cr.getFlattenedCells(), dcells.getFlattenedCells())); - for(Cell acell : cells){ + for(Cell acell : cr){ assertFalse(acell.isPartOfArrayFormulaGroup()); assertEquals(Cell.CELL_TYPE_BLANK, acell.getCellType()); } // cells C4:C6 are not included in array formula, // invocation of sheet.removeArrayFormula on any of them throws IllegalArgumentException - for(Cell acell : cells){ + for(Cell acell : cr){ try { sheet.removeArrayFormula(acell); fail("expected exception"); } catch (IllegalArgumentException e){ String ref = new CellReference(acell).formatAsString(); - assertEquals("Cell "+ref+" is not part of an array formula", e.getMessage()); + assertEquals("Cell "+ref+" is not part of an array formula.", e.getMessage()); } } } @@ -176,22 +202,22 @@ public abstract class BaseTestArrayFormulas extends TestCase { /** * Test that when reading a workbook from input stream, array formulas are recognized */ - public void testReadArrayFormula() { + public final void testReadArrayFormula() { Cell[] cells; - Workbook workbook = getTestDataProvider().createWorkbook(); + Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet1 = workbook.createSheet(); - cells = sheet1.setArrayFormula("SUM(A1:A3*B1:B3)", CellRangeAddress.valueOf("C4:C6")); + cells = sheet1.setArrayFormula("SUM(A1:A3*B1:B3)", CellRangeAddress.valueOf("C4:C6")).getFlattenedCells(); assertEquals(3, cells.length); - cells = sheet1.setArrayFormula("MAX(A1:A3*B1:B3)", CellRangeAddress.valueOf("A4:A6")); + cells = sheet1.setArrayFormula("MAX(A1:A3*B1:B3)", CellRangeAddress.valueOf("A4:A6")).getFlattenedCells(); assertEquals(3, cells.length); Sheet sheet2 = workbook.createSheet(); - cells = sheet2.setArrayFormula("MIN(A1:A3*B1:B3)", CellRangeAddress.valueOf("D2:D4")); + cells = sheet2.setArrayFormula("MIN(A1:A3*B1:B3)", CellRangeAddress.valueOf("D2:D4")).getFlattenedCells(); assertEquals(3, cells.length); - workbook = getTestDataProvider().writeOutAndReadBack(workbook); + workbook = _testDataProvider.writeOutAndReadBack(workbook); sheet1 = workbook.getSheetAt(0); for(int rownum=3; rownum <= 5; rownum++) { Cell cell1 = sheet1.getRow(rownum).getCell(2); @@ -207,4 +233,4 @@ public abstract class BaseTestArrayFormulas extends TestCase { assertTrue( cell1.isPartOfArrayFormulaGroup()); } } -}
\ No newline at end of file +} |