Bug 28031 - Error Setting formula for a cell
Summary: Error Setting formula for a cell
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-FINAL
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks: 34973
  Show dependency tree
 
Reported: 2004-03-29 20:06 UTC by Somendra Chathurvedi
Modified: 2008-03-13 08:52 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Somendra Chathurvedi 2004-03-29 20:06:20 UTC
I am trying to set a cell formula to =IF(ROUND(A2*B2*C2,2)>ROUND(B2*D2,2),ROUND
(A2*B2*C2,2),ROUND(B2*D2,2))
When the Excel workbook opens the value displayed is #Value!
Any help would be appreciated,
Somendra
Comment 1 Josh Micich 2008-03-13 08:52:57 UTC
Looks like this was fixed a while ago.
Here is a new junit test method just in case.

    public void test_bug28031() {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet();
        wb.setSheetName(0, "Sheet1");
        
        HSSFRow row = sheet.createRow(0);
        HSSFCell cell = row.createCell((short)0);
        String formulaText = "IF(ROUND(A2*B2*C2,2)>ROUND(B2*D2,2),ROUND(A2*B2*C2,2),ROUND(B2*D2,2))";
        cell.setCellFormula(formulaText);
       
        assertEquals(formulaText, cell.getCellFormula());
        if(false) {
            // this file can be inspected manually
            try {
                OutputStream os = new FileOutputStream("output28031.xls");
                wb.write(os);
                os.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

To be absolutely sure, I opened the file in Excel, and made sure the formula was correct there too.  I left that bit of the test disabled because I assume the rest of the test alone would have shown this bug.