/** * Construct a XSSFCell. * * @param row the parent row. * @param cell the xml bean containing information about the cell. */ protected XSSFCell(XSSFRow row, CTCell cell) { _cell = cell; _row = row; if (cell.getR() != null) { _cellNum = new CellReference(cell.getR()).getCol(); } _sharedStringSource = row.getSheet().getWorkbook().getSharedStringSource(); _stylesSource = row.getSheet().getWorkbook().getStylesSource(); }
private void setFormula(String formula, int formulaType) { XSSFWorkbook wb = _row.getSheet().getWorkbook(); if (formula == null) { wb.onDeleteFormula(this); if (_cell.isSetF()) _cell.unsetF(); return; } 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(); }