* Useful for verifying that the serialisation round trip
*/
public static HSSFWorkbook writeOutAndReadBack(HSSFWorkbook original) {
-
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
original.write(baos);
writeOutAndReadBack(workbook);
}
+ /**
+ * Note - part of this test is still failing, see
+ * {@link TestUnfixedBugs#test49612()}
+ */
+ @Test
+ public void bug49612_part() throws IOException {
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49612.xls");
+ HSSFSheet sh = wb.getSheetAt(0);
+ HSSFRow row = sh.getRow(0);
+ HSSFCell c1 = row.getCell(2);
+ HSSFCell d1 = row.getCell(3);
+ HSSFCell e1 = row.getCell(2);
+
+ assertEquals("SUM(BOB+JIM)", c1.getCellFormula());
+
+ // Problem 1: See TestUnfixedBugs#test49612()
+ // Problem 2: TestUnfixedBugs#test49612()
+
+ // Problem 3: These used to fail, now pass
+ HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
+ assertEquals("evaluating c1", 30.0, eval.evaluate(c1).getNumberValue(), 0.001);
+ assertEquals("evaluating d1", 30.0, eval.evaluate(d1).getNumberValue(), 0.001);
+ assertEquals("evaluating e1", 30.0, eval.evaluate(e1).getNumberValue(), 0.001);
+ }
+
@Test
public void bug51675(){
final List<Short> list = new ArrayList<Short>();
assertEquals("Defines!NR_To_A1", cRefSName.getCellFormula());
- // TODO How does Excel know to prefix this with the filename?
+ // TODO Correct this, so that the filename is shown too, see bug #56742
// This is what Excel itself shows
//assertEquals("'56737.xls'!NR_Global_B2", cRefWName.getCellFormula());
// TODO This isn't right, but it's what we currently generate....
assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
- // WARNING - this is wrong!
- // The file name should be showing, but bug #45970 is fixed
- // we seem to loose it
+ // TODO Correct this!
+ // The file name should be shown too, see bug #56742
assertEquals("Cost*Markup_Cost", cell.getCellFormula());
package org.apache.poi.hssf.usermodel;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
}
}
+ /**
+ * Note - some parts of this bug have been fixed, and have been
+ * transfered over to {@link TestBugs#bug49612_part()}
+ */
public void test49612() throws IOException {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49612.xls");
HSSFSheet sh = wb.getSheetAt(0);
assertEquals("SUM(BOB+JIM)", c1.getCellFormula());
- // Problem 1: java.lang.ArrayIndexOutOfBoundsException in org.apache.poi.hssf.model.LinkTable$ExternalBookBlock.getNameText
+ // Problem 1: Filename missing, see bug #56742
assertEquals("SUM('49612.xls'!BOB+'49612.xls'!JIM)", d1.getCellFormula());
- //Problem 2
+ //Problem 2: Filename missing, see bug #56742
//junit.framework.ComparisonFailure:
//Expected :SUM('49612.xls'!BOB+'49612.xls'!JIM)
//Actual :SUM(BOB+JIM)
assertEquals("SUM('49612.xls'!BOB+'49612.xls'!JIM)", e1.getCellFormula());
-
- HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
- assertEquals("evaluating c1", 30., eval.evaluate(c1).getNumberValue());
-
- //Problem 3: java.lang.RuntimeException: Unexpected arg eval type (org.apache.poi.hssf.record.formula.eval.NameXEval)
- assertEquals("evaluating d1", 30., eval.evaluate(d1).getNumberValue());
-
- assertEquals("evaluating e1", 30., eval.evaluate(e1).getNumberValue());
+
+ // Problem 3 - fixed and transfered
}
}