Examples of CTCellFormula


Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

    }

    void onReadCell(XSSFCell cell){
        //collect cells holding shared formulas
        CTCell ct = cell.getCTCell();
        CTCellFormula f = ct.getF();
        if (f != null && f.getT() == STCellFormulaType.SHARED && f.isSetRef() && f.getStringValue() != null) {
            // save a detached  copy to avoid XmlValueDisconnectedException,
            // this may happen when the master cell of a shared formula is changed
            sharedFormulas.put((int)f.getSi(), (CTCellFormula)f.copy());
        }
        if (f != null && f.getT() == STCellFormulaType.ARRAY && f.getRef() != null) {
            arrayFormulas.add(CellRangeAddress.valueOf(f.getRef()));
        }
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

     */
    public String getCellFormula() {
        int cellType = getCellType();
        if(cellType != CELL_TYPE_FORMULA) throw typeMismatch(CELL_TYPE_FORMULA, cellType, false);

        CTCellFormula f = cell.getF();
        if(f.getT() == STCellFormulaType.SHARED){
            return convertSharedFormula((int)f.getSi());
        } else {
            return f.getStringValue();
        }
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

        XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
        //validate through the FormulaParser
        FormulaParser.parse(formula, fpb, FormulaType.CELL, wb.getSheetIndex(getSheet()));

        CTCellFormula f =  CTCellFormula.Factory.newInstance();
        f.setStringValue(formula);
        cell.setF(f);
        if(cell.isSetV()) cell.unsetV();
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

                }
                cell.setT(STCellType.S);
                break;
            case CELL_TYPE_FORMULA:
                if(!cell.isSetF()){
                    CTCellFormula f =  CTCellFormula.Factory.newInstance();
                    f.setStringValue("0");
                    cell.setF(f);
                    if(cell.isSetT()) cell.unsetT();
                }
                break;
            default:
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

    }

    void onReadCell(XSSFCell cell){
        //collect cells holding shared formulas
        CTCell ct = cell.getCTCell();
        CTCellFormula f = ct.getF();
        if(f != null && f.getT() == STCellFormulaType.SHARED && f.isSetRef() && f.getStringValue() != null){
            sharedFormulas.put((int)f.getSi(), cell);
        }
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

     */
    public String getCellFormula() {
        int cellType = getCellType();
        if(cellType != CELL_TYPE_FORMULA) throw typeMismatch(CELL_TYPE_FORMULA, cellType, false);

        CTCellFormula f = _cell.getF();
        if(f.getT() == STCellFormulaType.SHARED){
            return convertSharedFormula((int)f.getSi());
        }
        return f.getStringValue();
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

        XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
        //validate through the FormulaParser
        FormulaParser.parse(formula, fpb, FormulaType.CELL, wb.getSheetIndex(getSheet()));

        CTCellFormula f =  CTCellFormula.Factory.newInstance();
        f.setStringValue(formula);
        _cell.setF(f);
        if(_cell.isSetV()) _cell.unsetV();
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

                }
                _cell.setT(STCellType.S);
                break;
            case CELL_TYPE_FORMULA:
                if(!_cell.isSetF()){
                    CTCellFormula f =  CTCellFormula.Factory.newInstance();
                    f.setStringValue("0");
                    _cell.setF(f);
                    if(_cell.isSetT()) _cell.unsetT();
                }
                break;
            default:
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

     * Parse cell formula and re-assemble it back using the new sheet name
     *
     * @param cell the cell to update
     */
    private void updateFormula(XSSFCell cell, String oldName, String newName) {
        CTCellFormula f = cell.getCTCell().getF();
        if (f != null) {
            String formula = f.getStringValue();
            if (formula != null && formula.length() > 0) {
                int sheetIndex = _wb.getSheetIndex(cell.getSheet());
                Ptg[] ptgs = FormulaParser.parse(formula, _fpwb, FormulaType.CELL, sheetIndex);
                for (Ptg ptg : ptgs) {
                    updatePtg(ptg, oldName, newName);
                }
                String updatedFormula = FormulaRenderer.toFormulaString(_fpwb, ptgs);
                if (!formula.equals(updatedFormula)) f.setStringValue(updatedFormula);
            }
        }
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

    @Override
    public String getCellFormula() {
        int cellType = getCellType();
        if(cellType != CELL_TYPE_FORMULA) throw typeMismatch(CELL_TYPE_FORMULA, cellType, false);

        CTCellFormula f = _cell.getF();
        if (isPartOfArrayFormulaGroup() && f == null) {
            XSSFCell cell = getSheet().getFirstCellInArrayFormula(this);
            return cell.getCellFormula();
        }
        if (f.getT() == STCellFormulaType.SHARED) {
            return convertSharedFormula((int)f.getSi());
        }
        return f.getStringValue();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.