Package org.openxmlformats.schemas.spreadsheetml.x2006.main

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


        setFormula(formula, FormulaType.CELL);
    }

    /* package */ void setCellArrayFormula(String formula, CellRangeAddress range) {
        setFormula(formula, FormulaType.ARRAY);
        CTCellFormula cellFormula = _cell.getF();
        cellFormula.setT(STCellFormulaType.ARRAY);
        cellFormula.setRef(range.formatAsString());
    }
View Full Code Here


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

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

                }
                _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

            CTCell ctCell = cell.getCTCell();
            String r = new CellReference(rownum, cell.getColumnIndex()).formatAsString();
            ctCell.setR(r);

            if(ctCell.isSetF()){
                CTCellFormula f = ctCell.getF();
                String fmla = f.getStringValue();
                if(fmla.length() > 0) {
                    String shiftedFmla = shiftFormula(fmla, n);
                    f.setStringValue(shiftedFmla);
                }
                if(f.isSetRef()){ //Range of cells which the formula applies to.
                    String ref = f.getRef();
                    String shiftedRef = shiftFormula(ref, n);
                    f.setRef(shiftedRef);
                }
            }
        }
        setRowNum(rownum);
    }
View Full Code Here

     */
    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

                throw new IllegalArgumentException("Unparsable formula '" + formula + "'", e);
            }
            throw e;
        }

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

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

  }
 
  private static void shiftXSSFFormulas(PtgShifter shifter, int sheetIndex, XSSFCell cell, XSSFWorkbook book) {
        CTCell ctCell = cell.getCTCell();
        if (ctCell.isSetF()) {
            CTCellFormula f = ctCell.getF();
            String formula = f.getStringValue();
            if (formula.length() > 0) {
                String shiftedFormula = shiftXSSFFormula(book, sheetIndex, formula, shifter);
                if (shiftedFormula != null) {
                    f.setStringValue(shiftedFormula);
                }
            }

            if (f.isSetRef()) { //Range of cells which the formula applies to.
                String ref = f.getRef();
                String shiftedRef = shiftXSSFFormula(book, sheetIndex, ref, shifter);
                if (shiftedRef != null) f.setRef(shiftedRef);
            }
        }
  }
View Full Code Here

     */
    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

        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

TOP

Related Classes of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula

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.