예제 #1
0
 /**
  * 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();
 }
예제 #2
0
  /**
   * 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);
  }
예제 #3
0
  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();
  }
예제 #4
0
 /**
  * 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);
 }
예제 #5
0
 /**
  * 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());
 }
예제 #6
0
 /**
  * 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();
 }