You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Filippos Papadopoulos <fi...@talent.gr> on 2007/08/01 13:05:31 UTC

Reading a cell in EXCEL which contains a custom formula, returns error

Hi,
i have an XLS file which contains a function (macro) written in Visual 
Basic. The function is named link.
This function is used as a formula in some cell. E.g  =link(...).
The problem is that when HSSF reads these cells it retuns 
HSSFCell.CELL_TYPE_ERROR

Any ideas?


Here is my code:

       
                HSSFFormulaEvaluator evaluator = new 
HSSFFormulaEvaluator(sheet, workbook);
                CellReference cellReference = new CellReference(i, j);
                HSSFRow rw = sheet.getRow(cellReference.getRow());
                HSSFCell c = rw.getCell(cellReference.getCol());
                evaluator.setCurrentRow(rw);


                HSSFFormulaEvaluator.CellValue cellValue = 
evaluator.evaluate(c);
               
             switch (cellValue.getCellType()) {
                case HSSFCell.CELL_TYPE_BOOLEAN:
                    System.out.println(cellValue.getBooleanValue());
                    break;
                case HSSFCell.CELL_TYPE_NUMERIC:
                    System.out.println(cellValue.getNumberValue());
                    break;
                case HSSFCell.CELL_TYPE_STRING:
                    System.out.println(cellValue.getRichTextStringValue());
                    break;
                case HSSFCell.CELL_TYPE_BLANK:
                    System.out.println("BLANK");
                    break;
                case HSSFCell.CELL_TYPE_ERROR:
                    System.out.println(" ERROR ");
                    break;
 
                }
            }





Thanks.


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