Package org.zkoss.poi.ss.usermodel

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


        if (!dstInRange) { //so we shall copy this data validation to dst cell
          dataValidation.getRegions().addCellRangeAddress(dstRow, dstCol, dstRow, dstCol);
        }
      }
    } else {
      final DataValidationHelper helper = dstSheet.getDataValidationHelper();
      for(DataValidation dataValidation : dataValidations) {
        CellRangeAddressList addrList = dataValidation.getRegions();
        boolean srcInRange = false;
        for(int j = addrList.countRanges(); --j >= 0;) {
          final CellRangeAddress addr = addrList.getCellRangeAddress(j);
          if (!srcInRange) {
            srcInRange = addr.isInRange(srcRow, srcCol);
          }
          if (srcInRange) {
            break;
          }
        }
        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


  //20110511, peterkuo@potix.com
  public static void setDataValidationToRange(Range range, String[] list) {
    if (range.getSheet() instanceof HSSFSheet) {
      //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

  //20110511, peterkuo@potix.com
  public static void setDataValidationToRange(Range range, Range ref){
    if (range.getSheet() instanceof HSSFSheet) {
      //TODO: not yet implemented for 2003
    }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

    sheet = spreadsheet.getSelectedSheet();
    initValidation();
  }

  private void initValidation() {
    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.DataValidationHelper

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.