poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amir Riaz <amir.riaz....@gmail.com>
Subject not able to calculate the formulas properly
Date Sat, 09 Jan 2010 12:00:48 GMT
I have the following code to evaluate the formula

switch (cell.getCellType())
        {
            case Cell.CELL_TYPE_FORMULA:
            {
                try
                {
                    CellValue cval = this.evaluator.evaluate(cell);
                    switch (cval.getCellType())
                    {
                        case Cell.CELL_TYPE_NUMERIC:
                        {
                            if (DateUtil.isCellDateFormatted(cell))
                            {

rowData.append(dateFormat.format(cval.getNumberValue()));
                                hasData = true;
                            }
                            else
                            {

rowData.append(numberFormat.format(cval.getNumberValue()));
                                hasData = true;
                            }
                            break;
                        }
                        case Cell.CELL_TYPE_STRING:
                        {

rowData.append(cval.getStringValue().trim().replaceAll("\n", ""));
                            hasData = true;
                            break;
                        }
                        case Cell.CELL_TYPE_BOOLEAN:
                        {
                            rowData.append(cval.getBooleanValue());
                            hasData = true;
                            break;
                        }
                        case Cell.CELL_TYPE_ERROR:
                        {
                            int eval=cval.getErrorValue();
                            if (eval==DIVIDE_BY_ZERO)
                            rowData.append("0");
                            hasData = true;
                            break;
                        }
                        case Cell.CELL_TYPE_BLANK:
                        {
                            rowData.append("");
                            hasData = true;
                            break;
                        }
                    }
                }

after conversion two sheet correct values but the third sheet contain
complex formula and values are not calculate correctly

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message