Package org.apache.poi.hssf.record

Examples of org.apache.poi.hssf.record.FormulaRecord$SpecialCachedValue



    private void handleFormula(Record record)
    {
           
        FormulaRecord formulaRec = (FormulaRecord) record;
           
       
        Ptg ptg = formulaRec.peekExpressionToken();
       
       
        if (ptg instanceof Ref3DPtg)
        {
           
            Ref3DPtg ptg3D = (Ref3DPtg)ptg;
           
            HSSFSheet sheet = _workbook.getSheetAt(ptg3D.getExternSheetIndex() + 1 );     
            HSSFRow row     = sheet.getRow(ptg3D.getRow())
            HSSFCell cell   = row.getCell(ptg3D.getColumn());
           
            _currentSheetListener.newCell( formulaRec.getRow( ),
                    formulaRec.getColumn( ),
                                       "" + cell.getStringCellValue() );
                   
        }
    }
View Full Code Here


        }
        int sheetIndex = _book.getSheetIndex(_sheet);
        Ptg[] ptgs = HSSFFormulaParser.parse(formula, _book, FormulaType.CELL, sheetIndex);
        setCellType(CELL_TYPE_FORMULA, false, row, col, styleIndex);
        FormulaRecordAggregate agg = (FormulaRecordAggregate) _record;
        FormulaRecord frec = agg.getFormulaRecord();
        frec.setOptions((short) 2);
        frec.setValue(0);

        //only set to default if there is no extended format index already set
        if (agg.getXFIndex() == (short)0) {
            agg.setXFIndex((short) 0x0f);
        }
View Full Code Here

            default:
                throw typeMismatch(CELL_TYPE_NUMERIC, _cellType, false);
            case CELL_TYPE_FORMULA:
                break;
        }
        FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord();
        checkFormulaCachedValueType(CELL_TYPE_NUMERIC, fr);
        return fr.getValue();
    }
View Full Code Here

            case CELL_TYPE_NUMERIC:
                return ((NumberRecord)_record).getValue() != 0;

            case CELL_TYPE_FORMULA:
                // use cached formula result if it's the right type:
                FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord();
                checkFormulaCachedValueType(CELL_TYPE_BOOLEAN, fr);
                return fr.getCachedBooleanValue();
            // Other cases convert to false
            // These choices are not well justified.
            case CELL_TYPE_ERROR:
            case CELL_TYPE_BLANK:
                return false;
View Full Code Here

                break;
            default:
                throw new IllegalStateException("Unexpected cell type (" + _cellType + ")");
        }
        FormulaRecordAggregate fra = ((FormulaRecordAggregate)_record);
        FormulaRecord fr = fra.getFormulaRecord();
        switch (fr.getCachedResultType()) {
            case CELL_TYPE_BOOLEAN:
                return fr.getCachedBooleanValue() ? "TRUE" : "FALSE";
            case CELL_TYPE_STRING:
                return fra.getStringValue();
            case CELL_TYPE_NUMERIC:
                return NumberToTextConverter.toText(fr.getValue());
            case CELL_TYPE_ERROR:
                   return HSSFErrorConstants.getText(fr.getCachedErrorValue());
        }
        throw new IllegalStateException("Unexpected formula result type (" + _cellType + ")");
    }
View Full Code Here

            default:
                throw typeMismatch(CELL_TYPE_BOOLEAN, _cellType, false);
            case CELL_TYPE_FORMULA:
                break;
        }
        FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord();
        checkFormulaCachedValueType(CELL_TYPE_BOOLEAN, fr);
        return fr.getCachedBooleanValue();
    }
View Full Code Here

            default:
                throw typeMismatch(CELL_TYPE_ERROR, _cellType, false);
            case CELL_TYPE_FORMULA:
                break;
        }
        FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord();
        checkFormulaCachedValueType(CELL_TYPE_ERROR, fr);
        return (byte) fr.getCachedErrorValue();
    }
View Full Code Here

    public TestFormulaRecordAggregate(String arg) {
        super(arg);
    }
   
    public void testClone() {
        FormulaRecord f = new FormulaRecord();
        StringRecord s = new StringRecord();
        FormulaRecordAggregate fagg = new FormulaRecordAggregate(f,s);
        FormulaRecordAggregate newFagg = (FormulaRecordAggregate) fagg.clone();
        assertTrue("objects are different", fagg!=newFagg);
        assertTrue("deep clone", fagg.getFormulaRecord() != newFagg.getFormulaRecord());
View Full Code Here

            case SSTRecord.sid: // holds all the strings for LabelSSTRecords
                sstRecord = (SSTRecord) record;
                break;

            case FormulaRecord.sid: // Cell value from a formula
                FormulaRecord formula = (FormulaRecord) record;
                addCell(record, new NumberCell(formula.getValue(), format));
                break;

            case LabelRecord.sid: // strings stored directly in the cell
                LabelRecord label = (LabelRecord) record;
                addTextCell(record, label.getValue());
View Full Code Here

            String str = null;
            switch (sid) {

                /* FormulaRecord: Cell value from a formula */
                case FormulaRecord.sid:
                    FormulaRecord formulaRecord = (FormulaRecord)record;
                    double fmlValue = formulaRecord.getValue();
                    str = toString(fmlValue, dfIdx, dataFormat);
                    str = addText(str);
                    break;

                /* LabelRecord: strings stored directly in the cell */
 
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.FormulaRecord$SpecialCachedValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.