private void correctDataValidation(final Sheet sheet, final RecordOperation recordOperation) {

        if(recordOperation.isNotExecuteRecordOperation()) {
            return;
        }

        //TODO: セルの結合も考慮する

        // 操作をしていないセルの範囲の取得
        final CellRangeAddress notOperateRange = new CellRangeAddress(
                recordOperation.getTopLeftPoisitoin().y,
                recordOperation.getBottomRightPosition().y,
                recordOperation.getTopLeftPoisitoin().x,
                recordOperation.getBottomRightPosition().x - recordOperation.getCountInsertRecord()
                );

        final List<? extends DataValidation> list = sheet.getDataValidations();
        for(DataValidation validation : list) {

            final CellRangeAddressList region = validation.getRegions().copy();
            boolean changedRange = false;
            for(CellRangeAddress range : region.getCellRangeAddresses()) {

                if(notOperateRange.isInRange(range.getFirstRow(), range.getFirstColumn())) {
                    // 自身のセルの範囲の場合は、行の範囲を広げる
                    range.setLastColumn(recordOperation.getBottomRightPosition().x);
                    changedRange = true;

                } else if(notOperateRange.getLastColumn() < range.getFirstColumn()) {
                    /*
                     * VerticalRecordsの場合は、挿入・削除はないので、自身以外の範囲は修正しない。
                     */
                }

            }

            // 修正した規則を、再度シートに追加する
            if(changedRange) {
                boolean updated = POIUtils.updateDataValidationRegion(sheet, validation.getRegions(), region);
                assert updated == true;
            }
        }

    }
private void correctDataValidation ( final Sheet sheet , final RecordOperation recordOperation ) { if ( recordOperation . isNotExecuteRecordOperation ( ) ) { return ; } final CellRangeAddress notOperateRange = new CellRangeAddress ( recordOperation . getTopLeftPoisitoin ( ) . y , recordOperation . getBottomRightPosition ( ) . y , recordOperation . getTopLeftPoisitoin ( ) . x , recordOperation . getBottomRightPosition ( ) . x - recordOperation . getCountInsertRecord ( ) ) ; final List < ? extends DataValidation > list = sheet . getDataValidations ( ) ; for ( DataValidation validation : list ) { final CellRangeAddressList region = validation . getRegions ( ) . copy ( ) ; boolean changedRange = false ; for ( CellRangeAddress range : region . getCellRangeAddresses ( ) ) { if ( notOperateRange . isInRange ( range . getFirstRow ( ) , range . getFirstColumn ( ) ) ) { range . setLastColumn ( recordOperation . getBottomRightPosition ( ) . x ) ; changedRange = true ; } else if ( notOperateRange . getLastColumn ( ) < range . getFirstColumn ( ) ) { } } if ( changedRange ) { boolean updated = POIUtils . updateDataValidationRegion ( sheet , validation . getRegions ( ) , region ) ; assert updated == true ; } } }
セルの入力規則の範囲を修正する。
@param sheet
@param recordOperation