Esempio n. 1
0
  public Cell getCell(CellCoord cell) {
    int sheet = getSheet(cell);

    try {
      return workbook.getSheetAt(sheet).getRow(cell.getRow()).getCell(cell.getCol());
    } catch (Exception ex) {
      return null;
    }
  }
Esempio n. 2
0
  public String getStringValue(CellCoord cellCoord) {
    int sheet = getSheet(cellCoord);

    if (sheet < 0 || cellCoord.getCol() < 0 || cellCoord.getRow() < 0) return null;

    Cell cell = getCell(cellCoord);

    if (cell == null) return null;

    switch (cell.getCellType()) {
      case Cell.CELL_TYPE_NUMERIC:
        Double _value = cell.getNumericCellValue();
        return _value == _value.longValue()
            ? String.format("%d", _value.longValue())
            : String.format("%s", _value);
      case Cell.CELL_TYPE_STRING:
        return cell.getStringCellValue();
      default:
        break;
    }

    return "";
  }
Esempio n. 3
0
  public Double getDoubleValue(CellCoord cellCoord) {
    int sheet = getSheet(cellCoord);

    if (sheet < 0 || cellCoord.getCol() < 0 || cellCoord.getRow() < 0) return null;

    Double result = 0d;
    Cell cell = getCell(cellCoord);

    int cellType =
        cell.getCellType() == Cell.CELL_TYPE_FORMULA
            ? cell.getCachedFormulaResultType()
            : cell.getCellType();

    switch (cellType) {
      case Cell.CELL_TYPE_NUMERIC:
        return cell.getNumericCellValue();
      case Cell.CELL_TYPE_STRING:
        return ParserUtils.getDoubleResult(cell.getStringCellValue());
      default:
        break;
    }

    return result;
  }