annotated previous changelist(641964) with wrong buzilla number. Previous changes...
[poi.git] / src / scratchpad / testcases / org / apache / poi / hssf / usermodel / TestBug44691.java
blob59b04b498a4df1e7ff37ae58c14d15c97d7704a8
1 /* ====================================================================
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 ==================================================================== */
17 package org.apache.poi.hssf.usermodel;
19 import java.io.ByteArrayInputStream;
20 import java.io.ByteArrayOutputStream;
22 import junit.framework.TestCase;
24 import org.apache.poi.hssf.util.CellReference;
26 /**
27 * The PMT formula seems to be giving some grief
29 public final class TestBug44691 extends TestCase {
30 String dirname;
32 protected void setUp() throws Exception {
33 super.setUp();
34 dirname = System.getProperty("HSSF.testdata.path");
37 public void DISABLEDtestBug44691() throws Exception {
38 HSSFWorkbook outWorkbook = new HSSFWorkbook();
39 HSSFSheet outPMTSheet = outWorkbook.createSheet("PMT Sheet");
40 HSSFRow row = outPMTSheet.createRow((short) 0);
41 HSSFCell cell = row.createCell((short) 0);
42 cell.setCellType(HSSFCell.CELL_TYPE_FORMULA);
43 cell.setCellFormula("PMT(0.09/12,48,-10000)");
45 ByteArrayOutputStream baos = new ByteArrayOutputStream();
46 outWorkbook.write(baos);
47 ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
49 HSSFWorkbook inWorkbook = new HSSFWorkbook(bais);
51 HSSFSheet inPMTSheet = inWorkbook.getSheet("PMT Sheet");
52 HSSFFormulaEvaluator evaluator = new
53 HSSFFormulaEvaluator(inPMTSheet, inWorkbook);
54 CellReference cellReference = new CellReference("A1");
55 HSSFRow inRow = inPMTSheet.getRow(cellReference.getRow());
56 HSSFCell inCell = inRow.getCell(cellReference.getCol());
58 assertEquals("PMT(0.09/12,48,-10000)",
59 inCell.getCellFormula());
60 assertEquals(HSSFCell.CELL_TYPE_FORMULA, inCell.getCellType());
62 evaluator.setCurrentRow(inRow);
63 HSSFFormulaEvaluator.CellValue inCellValue =
64 evaluator.evaluate(inCell);
66 assertEquals(0, inCellValue.getErrorValue());
67 assertEquals(HSSFCell.CELL_TYPE_NUMERIC, inCellValue.getCellType());
68 assertEquals(248.85, inCellValue.getNumberValue(), 0.0001);