Package org.zkoss.poi.ss.usermodel

Examples of org.zkoss.poi.ss.usermodel.DataValidation


        if (!srcInRange) { //this validation is not associated to source cell
          continue;
        }
        //so we shall copy this data validation to dst cell
        final DataValidationConstraint constraint = BookHelper.getConstraint(dataValidation);
        DataValidation dstDataValidation = BookHelper.getDataValidationByConstraint(constraint, getDataValidations(dstSheet));
        if (dstDataValidation == null) {
          final CellRangeAddressList dstAddrList = new CellRangeAddressList(dstRow, dstCol, dstRow, dstCol);
          dstDataValidation = helper.createValidation(constraint, dstAddrList);
          dstSheet.addValidationData(dstDataValidation);
        } else {
          CellRangeAddressList dstAddrList = dstDataValidation.getRegions();
          dstAddrList.addCellRangeAddress(dstRow, dstCol, dstRow, dstCol);
        }
      }
    }
  }
View Full Code Here


      //TODO: not yet implemented for 2003
    }else{
      final DataValidationHelper helper = range.getSheet().getDataValidationHelper();
      DataValidationConstraint constraint = new XSSFDataValidationConstraint(list);
      CellRangeAddressList dstAddrList = new CellRangeAddressList(range.getRow(),range.getLastRow(), range.getColumn(), range.getLastColumn());   
      DataValidation dstDataValidation = helper.createValidation(constraint, dstAddrList);
      range.getSheet().addValidationData(dstDataValidation);     
    }
  }
View Full Code Here

    }else{
      final DataValidationHelper helper = range.getSheet().getDataValidationHelper();
      CellRangeAddress refCRA = new CellRangeAddress(ref.getRow(),ref.getLastRow(),ref.getColumn(),ref.getLastColumn());
      DataValidationConstraint constraint = new XSSFDataValidationConstraint(ValidationType.LIST,convertToAbsoluteString(refCRA));
      CellRangeAddressList dstAddrList = new CellRangeAddressList(range.getRow(),range.getLastRow(), range.getColumn(), range.getLastColumn());   
      DataValidation dstDataValidation = helper.createValidation(constraint, dstAddrList);
      range.getSheet().addValidationData(dstDataValidation);           
   
  }
View Full Code Here

  private static boolean isString(Object value) {
    return value instanceof String;
  }
 
  /*package*/ static DataValidation validate(Worksheet sheet, int row, int col, Object value, int cellType) {
    DataValidation dv = sheet.getDataValidation(row, col);
    //no validation constraint
    if (dv == null) {
      return null;
    }
    final DataValidationConstraint constraint = dv.getValidationConstraint();
    //allow any value => no need to do validation
    if (constraint.getValidationType() == ValidationType.ANY) { //can be any value, meaning no validation
      return null;
    }
    //ignore empty and value is empty
    if (value == null || (value instanceof String && ((String)value).length() == 0)) {
      if (dv.getEmptyCellAllowed()) {
        return null;
      }
    }
    //get new evaluated formula value
    if (cellType == Cell.CELL_TYPE_FORMULA) {
View Full Code Here

    }
    if (_inCallback) { //skip validation check
      return true;
    }
    final Range rng = Ranges.range(sheet, row, col);
    final DataValidation dv = rng.validate(txt);
    if (dv != null) {
      if (dv.getShowErrorBox()) {
        String errTitle = dv.getErrorBoxTitle();
        String errText = dv.getErrorBoxText();
        if (errTitle == null) {
          errTitle = "ZK Spreadsheet";
        }
        if (errText == null) {
          errText = "The value you entered is not valid.\n\nA user has restricted values that can be entered into this cell.";
        }
        final int errStyle = dv.getErrorStyle();
        switch(errStyle) {
          case ErrorStyle.STOP:
          {
            final int btn = Messagebox.show(
              errText, errTitle, Messagebox.RETRY|Messagebox.CANCEL,
View Full Code Here

    DataValidationHelper dvh = sheet.getDataValidationHelper();
    String[] vals = { "STFI", "Treasury", "Fixed Income", "Trade Capture",
        "Unknow" };
    DataValidationConstraint dvc = dvh.createExplicitListConstraint(vals);
    CellRangeAddressList cral = new CellRangeAddressList(1, 100, 3, 3);
    DataValidation dv = dvh.createValidation(dvc, cral);
    sheet.addValidationData(dv);
  }
View Full Code Here

TOP

Related Classes of org.zkoss.poi.ss.usermodel.DataValidation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.