Package org.zkoss.poi.ss.util

Examples of org.zkoss.poi.ss.util.CellRangeAddressList


    }
    return null;
  }
 
  private Map convertDataValidationToJSON(DataValidation dv) {
    final CellRangeAddressList addrList = dv.getRegions();
    final int addrCount = addrList.countRanges();
    final List<Map> addrmapary = new ArrayList<Map>(addrCount);
    for (int j = 0; j < addrCount; ++j) {
      final CellRangeAddress addr = addrList.getCellRangeAddress(j);
      final int left = addr.getFirstColumn();
      final int right = addr.getLastColumn();
      final int top = addr.getFirstRow();
      final int bottom = addr.getLastRow();
      final Worksheet sheet = this.getSelectedSheet();
View Full Code Here


     
    @Override
    public void visitRecord(Record r) {
      if (r instanceof DVRecord) {
        final DVRecord dvRecord = (DVRecord) r;
        final CellRangeAddressList regions = dvRecord.getCellRangeAddress();
        final DataValidationConstraint constraint = createContraint(dvRecord);
        if (constraint != null) {
          HSSFDataValidation dataValidation = new HSSFDataValidation(regions, constraint);
          final boolean allowed = dvRecord.getEmptyCellAllowed();
          final int errStyle = dvRecord.getErrorStyle();
View Full Code Here

  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

    final int dstCol = dstCell.getColumnIndex();
   
    final List<? extends DataValidation> dataValidations= BookHelper.getDataValidations(srcSheet);
    if (dstSheet.equals(srcSheet)) {
      for(DataValidation dataValidation : dataValidations) {
        CellRangeAddressList addrList = dataValidation.getRegions();
        boolean srcInRange = false;
        boolean dstInRange = false;
        for(int j = addrList.countRanges(); --j >= 0;) {
          final CellRangeAddress addr = addrList.getCellRangeAddress(j);
          if (!srcInRange) {
            srcInRange = addr.isInRange(srcRow, srcCol);
          }
          if (!dstInRange) {
            dstInRange = addr.isInRange(dstRow, dstCol);
          }
          if (srcInRange && dstInRange) { //no need to copy
            break;
          }
        }
        if (!srcInRange) { //this validation is not associated to source cell
          continue;
        }
        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

    final int row = cell.getRowIndex();
    final int col = cell.getColumnIndex();
   
    final List<? extends DataValidation> dataValidations= BookHelper.getDataValidations(srcSheet);
    for(DataValidation dataValidation : dataValidations) {
      CellRangeAddressList addrList = dataValidation.getRegions();
      for(int j = addrList.countRanges(); --j >= 0;) {
        final CellRangeAddress addr = addrList.getCellRangeAddress(j);
        boolean inRange = addr.isInRange(row, col);
        if (inRange) {
          return dataValidation;
        }
      }
View Full Code Here

    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

      //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

      final int rngLastRow = range.getLastRow();
      final int rngLastCol = range.getLastColumn();
     
      final List<? extends DataValidation> dataValidations = BookHelper.getDataValidations(srcSheet);
        for(DataValidation dataValidation : dataValidations) {
          CellRangeAddressList addrList = dataValidation.getRegions();
          for(int j = addrList.countRanges(); --j >= 0;) {
            final CellRangeAddress addr = addrList.getCellRangeAddress(j);
            if (addr.isInRange(rngRow, rngCol, rngLastRow, rngLastCol)) {
              //TODO: not fully mimic the scenario as excel
              //have to remove the whole data validation first
              range.getSheet().removeValidationData(dataValidation);
              return;
View Full Code Here

TOP

Related Classes of org.zkoss.poi.ss.util.CellRangeAddressList

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.