Bug 18954 - Formulas inside If-statement are not recognized.
Summary: Formulas inside If-statement are not recognized.
Status: VERIFIED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P3 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-11 15:08 UTC by Frank Wolter
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments
offending excel file (13.50 KB, application/octet-stream)
2003-04-11 16:13 UTC, Danny Mui
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Wolter 2003-04-11 15:08:45 UTC
HSSFCell.getCellFormula() returns #NAME for formulas like
=WENN(A1>B1;"a1>b1";"A1<B1"). 
The same result for =WENN(ISTLEER(A1);"a1>b1";"A1<B1"). 

A Formula like
=WENN(A1;"a1>b1";"A1<B1") does work.
Comment 1 Danny Mui 2003-04-11 15:14:14 UTC
how is this formula entered? reading from an excel file or using the api?

don't recognize WENN but I guess that's just i18ed for IF?

Comment 2 Frank Wolter 2003-04-11 15:23:08 UTC
Yes, it is the IF-Formula. The formula is read from an Excel-File.
Comment 3 Danny Mui 2003-04-11 15:24:48 UTC
can you attach the file and/or short snippet of the code you're using?

thanks
Comment 4 Frank Wolter 2003-04-11 15:39:17 UTC
Hello Danny,

thanks for the fast reply

Frank Wolter

here is my (stripped) code:


  public boolean parseSheet(String sheetname ) 
  {
     m_SheetNameExcel = sheetname;
     m_SheetNameDisplay = m_SheetNameExcel;
     m_visibleRange = null;
     m_cellsWithSheetReferences.clear();
     HSSFCellStyle c_style;
     int col_n = 0;
     int row_n = 0;
     HSSFRow phyRow = null;
     HSSFSheet sheet    = m_workbook.getSheet(sheetname);
     HSSFFont cellfont  = m_workbook.getFontAt((short)0);

     logger.debug( "ENTER parseSheet(sheetname=" + sheetname + ")" );


     int rowNum = sheet.getLastRowNum();

     Iterator rows = sheet.rowIterator();
     HSSFRow row;
     while( rows.hasNext()) 
     {
            row = (HSSFRow) rows.next();
            row_n = row.getRowNum();

            // Iterate over each cell in the row and print out the cell's 
content
            Iterator cells = row.cellIterator();

            short fontindex;
            short c_bcolor;
            short c_fcolor;
            HSSFCell cell;

            while( cells.hasNext()) 
            {
                cell = (HSSFCell) cells.next();
                col_n = cell.getCellNum();
                logger.info("Working on cell(row="+ (row_n) + ", col=" + 
(col_n) + ")");

                try
                {
                    c_style = cell.getCellStyle();

                    switch ( cell.getCellType() ) {
                        case HSSFCell.CELL_TYPE_NUMERIC:

                            break;
                        case HSSFCell.CELL_TYPE_STRING:
                            break;
                        case HSSFCell.CELL_TYPE_BLANK:
                            break;
                        case HSSFCell.CELL_TYPE_FORMULA:
// HERE THE PROBLEM OCCURS:
                            logger.debug("Formula: " + cell.getCellFormula());
                            break;
                        default:
                            logger.error( "unsuported cell type in sheet'" + 
sheetname + "', row=" +  row_n + ", col=" +  col_n);

                            break;
                    }
                }
                catch ( Exception e )
                {
                    logger.error("Exception for cell("+ row_n + ", " + col_n 
+ ") Exception:" + e.toString());
                    e.printStackTrace();

                } /* end catch() */  

            } //end while

        } //end first while
Comment 5 Danny Mui 2003-04-11 15:56:36 UTC
can you attach the file you're reading as well?
Comment 6 Danny Mui 2003-04-11 16:13:21 UTC
Created attachment 5805 [details]
offending excel file
Comment 7 Danny Mui 2003-05-08 00:19:47 UTC
We had some formula parser patches and the result of reading/writing your excel
files keeps the values intact.  Please verify.
Comment 8 Frank Wolter 2003-06-03 13:26:00 UTC
Thanks for the correction. Everything works fine with version 2.0 pre1.