poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 54349] New: Rate formula inconsistency with long periods
Date Tue, 25 Dec 2012 14:09:28 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=54349

            Bug ID: 54349
           Summary: Rate formula inconsistency with long periods
           Product: POI
           Version: 3.8
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
          Assignee: dev@poi.apache.org
          Reporter: sebas.lillo@gmail.com
    Classification: Unclassified

in order to emulate excel's rate function, I'm using apache poi v3.8. My code
is:

public static void main(String[] args) {

    int nper = 120;
    double pmt = 28.1;
    double pv = 2400;

    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet sheet = workbook.createSheet();

    FormulaEvaluator evaluator =
workbook.getCreationHelper().createFormulaEvaluator();

    Row row = sheet.createRow(0);

    Cell np = row.createCell(0);
    np.setCellValue(nper);

    Cell pt = row.createCell(1);
    pt.setCellValue(pmt);

    Cell cpv = row.createCell(2);
    cpv.setCellValue(-pv);

    Cell rate = row.createCell(3); 
    rate.setCellFormula("RATE(A1,B1,C1)");

    evaluator.evaluateFormulaCell(rate);
    double drate = rate.getNumericCellValue() * 100;
    System.out.println("RATE: " + drate);

}

which output is the same as excel: 0.599

But if I try the same calculation, this time with the values:

int nper = 360;
double pmt = 15.9;
double pv = 2400;


In excel I get 0.580, and the program returns 3.722909655790338E-14. Is this a
known bug ? Any hints ? Thanks

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message