protected XSSFCell nextNumericCellOrBlank() { XSSFCell cell = nextCell(); if (cell.getCellTypeEnum() == CellType.BLANK || (cell.getCellTypeEnum() == CellType.STRING && cell.getStringCellValue().isEmpty())) { return null; } if (cell.getCellTypeEnum() == CellType.STRING) { throw new IllegalStateException(currentPosition() + ": The cell with value (" + cell.getStringCellValue() + ") has a string type but should be numeric."); } return cell; }
protected XSSFCell nextBooleanCell() { XSSFCell cell = nextCell(); if (cell.getCellTypeEnum() == CellType.STRING) { throw new IllegalStateException(currentPosition() + ": The cell with value (" + cell.getStringCellValue() + ") has a string type but should be boolean."); } if (cell.getCellTypeEnum() == CellType.NUMERIC) { throw new IllegalStateException(currentPosition() + ": The cell with value (" + cell.getNumericCellValue() + ") has a numeric type but should be a boolean."); } return cell; }
protected XSSFCell nextStringCell() { XSSFCell cell = nextCell(); if (cell.getCellTypeEnum() == CellType.NUMERIC) { throw new IllegalStateException(currentPosition() + ": The cell with value (" + cell.getNumericCellValue() + ") has a numeric type but should be a string."); } return cell; }
protected XSSFCell nextNumericCell() { XSSFCell cell = nextCell(); if (cell.getCellTypeEnum() == CellType.STRING) { throw new IllegalStateException(currentPosition() + ": The cell with value (" + cell.getStringCellValue() + ") has a string type but should be numeric."); } return cell; }
protected void readIntConstraintParameterLine(String name, Consumer<Integer> consumer, String constraintDescription) { nextRow(); readHeaderCell(name); XSSFCell weightCell = nextCell(); if (consumer != null) { if (weightCell.getCellTypeEnum() != CellType.NUMERIC) { throw new IllegalArgumentException(currentPosition() + ": The value (" + weightCell.getStringCellValue() + ") for constraint (" + name + ") must be a number and the cell type must be numeric."); } double value = weightCell.getNumericCellValue(); if (((double) ((int) value)) != value) { throw new IllegalArgumentException(currentPosition() + ": The value (" + value + ") for constraint (" + name + ") must be an integer."); } consumer.accept((int) value); } else { if (weightCell.getCellTypeEnum() == CellType.NUMERIC || !weightCell.getStringCellValue().equals("n/a")) { throw new IllegalArgumentException(currentPosition() + ": The value (" + weightCell.getStringCellValue() + ") for constraint (" + name + ") must be an n/a."); } } readHeaderCell(constraintDescription); }
protected void readLongConstraintParameterLine(String name, Consumer<Long> consumer, String constraintDescription) { nextRow(); readHeaderCell(name); XSSFCell weightCell = nextCell(); if (consumer != null) { if (weightCell.getCellTypeEnum() != CellType.NUMERIC) { throw new IllegalArgumentException(currentPosition() + ": The value (" + weightCell.getStringCellValue() + ") for constraint (" + name + ") must be a number and the cell type must be numeric."); } double value = weightCell.getNumericCellValue(); if (((double) ((long) value)) != value) { throw new IllegalArgumentException(currentPosition() + ": The value (" + value + ") for constraint (" + name + ") must be a (long) integer."); } consumer.accept((long) value); } else { if (weightCell.getCellTypeEnum() == CellType.NUMERIC || !weightCell.getStringCellValue().equals("n/a")) { throw new IllegalArgumentException(currentPosition() + ": The value (" + weightCell.getStringCellValue() + ") for constraint (" + name + ") must be an n/a."); } } readHeaderCell(constraintDescription); }
protected XSSFCell nextNumericCellOrBlank() { XSSFCell cell = nextCell(); if (cell.getCellTypeEnum() == CellType.BLANK || (cell.getCellTypeEnum() == CellType.STRING && cell.getStringCellValue().isEmpty())) { return null; } if (cell.getCellTypeEnum() == CellType.STRING) { throw new IllegalStateException(currentPosition() + ": The cell with value (" + cell.getStringCellValue() + ") has a string type but should be numeric."); } return cell; }
protected XSSFCell nextBooleanCell() { XSSFCell cell = nextCell(); if (cell.getCellTypeEnum() == CellType.STRING) { throw new IllegalStateException(currentPosition() + ": The cell with value (" + cell.getStringCellValue() + ") has a string type but should be boolean."); } if (cell.getCellTypeEnum() == CellType.NUMERIC) { throw new IllegalStateException(currentPosition() + ": The cell with value (" + cell.getNumericCellValue() + ") has a numeric type but should be a boolean."); } return cell; }
protected XSSFCell nextStringCell() { XSSFCell cell = nextCell(); if (cell.getCellTypeEnum() == CellType.NUMERIC) { throw new IllegalStateException(currentPosition() + ": The cell with value (" + cell.getNumericCellValue() + ") has a numeric type but should be a string."); } return cell; }
protected XSSFCell nextNumericCell() { XSSFCell cell = nextCell(); if (cell.getCellTypeEnum() == CellType.STRING) { throw new IllegalStateException(currentPosition() + ": The cell with value (" + cell.getStringCellValue() + ") has a string type but should be numeric."); } return cell; }
protected void readLongConstraintParameterLine(String name, Consumer<Long> consumer, String constraintDescription) { nextRow(); readHeaderCell(name); XSSFCell weightCell = nextCell(); if (consumer != null) { if (weightCell.getCellTypeEnum() != CellType.NUMERIC) { throw new IllegalArgumentException(currentPosition() + ": The value (" + weightCell.getStringCellValue() + ") for constraint (" + name + ") must be a number and the cell type must be numeric."); } double value = weightCell.getNumericCellValue(); if (((double) ((long) value)) != value) { throw new IllegalArgumentException(currentPosition() + ": The value (" + value + ") for constraint (" + name + ") must be a (long) integer."); } consumer.accept((long) value); } else { if (weightCell.getCellTypeEnum() == CellType.NUMERIC || !weightCell.getStringCellValue().equals("n/a")) { throw new IllegalArgumentException(currentPosition() + ": The value (" + weightCell.getStringCellValue() + ") for constraint (" + name + ") must be an n/a."); } } readHeaderCell(constraintDescription); }
protected void readIntConstraintParameterLine(String name, Consumer<Integer> consumer, String constraintDescription) { nextRow(); readHeaderCell(name); XSSFCell weightCell = nextCell(); if (consumer != null) { if (weightCell.getCellTypeEnum() != CellType.NUMERIC) { throw new IllegalArgumentException(currentPosition() + ": The value (" + weightCell.getStringCellValue() + ") for constraint (" + name + ") must be a number and the cell type must be numeric."); } double value = weightCell.getNumericCellValue(); if (((double) ((int) value)) != value) { throw new IllegalArgumentException(currentPosition() + ": The value (" + value + ") for constraint (" + name + ") must be an integer."); } consumer.accept((int) value); } else { if (weightCell.getCellTypeEnum() == CellType.NUMERIC || !weightCell.getStringCellValue().equals("n/a")) { throw new IllegalArgumentException(currentPosition() + ": The value (" + weightCell.getStringCellValue() + ") for constraint (" + name + ") must be an n/a."); } } readHeaderCell(constraintDescription); }
private Object getCellValue(XSSFCell cell) { Object cellValue = null; CellType cellType = cell.getCellTypeEnum(); if (CellType.FORMULA == cellType) cellType = cell.getCachedFormulaResultTypeEnum();
CellType cellType=cell.getCellTypeEnum(); switch(cellType){ case STRING: