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;
}
}