poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre Lavignotte" <pierre.lavigno...@gmail.com>
Subject Re: IndexBound-Exception by FormulaCell-Evaluation
Date Tue, 23 Sep 2008 08:18:58 GMT
Still no error...

Not sure but maybe you have a specific formula that is causing the error.
Print out the formula before calling the evaluator.evaluate(cell) method.

Pierre

On Tue, Sep 23, 2008 at 10:04 AM, Hardie82 <thomas.hartthaler@yahoo.de> wrote:
>
> Hi Pierre,
>
> here is the complete code of the function:
>
>        @SuppressWarnings("unchecked")
>        private void checkFormulaCells (HSSFSheet sheet, CkResult result) {
>                logger.debug("start checkFormulaCells");
>                HSSFRow row = null;
>                HSSFCell cell = null;
>                HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet,
> this.wbook);
>                ArrayList<String> errors = new ArrayList<String>();
>
>                CellValue cellValue = null;
>                for(Iterator<HSSFRow> rit = (Iterator<HSSFRow>)sheet.rowIterator();
> rit.hasNext(); ) {
>                        row = rit.next();
>                        evaluator.setCurrentRow(row);
>                        for(Iterator<HSSFCell> cit = (Iterator<HSSFCell>)row.cellIterator();
> cit.hasNext(); ) {
>                                cell = cit.next();
>                                if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA)
{
>                                        cellValue = evaluator.evaluate(cell);
>                                        switch (cellValue.getCellType()) {
>                                        case HSSFCell.CELL_TYPE_ERROR:
>                                                switch (cellValue.getErrorValue()) {
>                                                case ErrorConstants.ERROR_DIV_0:
>                                                        errors.add("cell.value.faulty.zerodivision");
break;
>                                                case ErrorConstants.ERROR_NAME:
>                                                        errors.add("cell.value.faulty.name");
break;
>                                                case ErrorConstants.ERROR_VALUE:
>                                                        errors.add("cells.value.faulty.value");
break;
>                                                default:
>                                                        errors.add("cell.value.faulty");
>                                                }
>                                        }
>
>                                        if(!cell.getCellStyle().getLocked())
>                                                errors.add("protection.disabled.formulacell");
>                                        if(errors.size() > 0)
>                                                result.addError((new CellReference(row.getRowNum(),
> cell.getCellNum())).formatAsString().replace("$", ""),
>                                                                                     
                  errors.toArray(new String[errors.size()]));
>                                        errors.clear();
>                                }
>
>
>                        }
>                }
>
>                logger.debug("finished checkFormulaCells");
>        }
>
> The sheet i get with a for-loop:
>
>                int anzSheets = wbook.getNumberOfSheets();
>                for (int i = 0; i < anzSheets; i++) {
>                        logger.info("start checking sheet \"" + wbook.getSheetName(i)
+ "\"");
>                        result = checkSheet(wbook.getSheetAt(i));
>                        result.setSheetName(wbook.getSheetName(i));
>                        resultList.add(result);
>                        logger.info("finished checking sheet \"" + wbook.getSheetName(i)
+ "\"");
>                }
>
> I use version 3.5_beta.
>
> Hardie
>
>
> Pierre Lavignotte wrote:
>>
>> Hi,
>>
>> I can run your code without error.
>> Can you tell me how you create your "evaluator" instance and how you
>> get your "sheet" reference ?
>> Also, wich version of POI are you using ?
>>
>> Pierre
>>
>
> --
> View this message in context: http://www.nabble.com/IndexBound-Exception-by-FormulaCell-Evaluation-tp19622168p19623049.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>



-- 
Cordialement,
Pierre Lavignotte
Ingénieur Conception & Développement
http://pierre.lavignotte.googlepages.com

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


Mime
View raw message