/** * 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(); }
/** * Assign a hypelrink to this cell * * @param hyperlink the hypelrink to associate with this cell */ public void setHyperlink(Hyperlink hyperlink) { XSSFHyperlink link = (XSSFHyperlink) hyperlink; // Assign to us link.setCellReference(new CellReference(_row.getRowNum(), _cellNum).formatAsString()); // Add to the lists getSheet().setCellHyperlink(link); }
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(); }
/** * Returns hyperlink associated with this cell * * @return hyperlink associated with this cell or <code>null</code> if not found */ public XSSFHyperlink getHyperlink() { return getSheet().getHyperlink(_row.getRowNum(), _cellNum); }
/** * Returns cell comment associated with this cell * * @return the cell comment associated with this cell or <code>null</code> */ public XSSFComment getCellComment() { return getSheet().getCellComment(_row.getRowNum(), getColumnIndex()); }
/** * Returns row index of a row in the sheet that contains this cell * * @return zero-based row index of a row in the sheet that contains this cell */ public int getRowIndex() { return _row.getRowNum(); }