Fix Excel Removing Data Validation from Large Apache POI Workbooks
Question details
The user needs Excel to retain data validation rules in a large workbook generated with Apache POI.

- Product
- Microsoft Excel and Apache POI
- Device & OS
- not provided
- Scenario
- An Apache POI workbook contains approximately 80,000 rows, two validated columns, and multiple lookup lists.
- Observed behavior
- Excel repairs the large workbook by removing data validation rules, while a smaller workbook opens correctly.
Check Excel's repair message or log for the affected worksheet and validation records. Identify whether cells share the same validation rule or need different lookup lists before consolidating them.
Consolidate Apache POI data validation rules
Use fewer validation records when many cells share the same list or condition.
A large number of individual validation references can contribute to workbook repair. Consolidation preserves the intended behavior only when the cells in a combined range use the same rule.
In the Apache POI generation code, find calls to createValidation and addValidationData. Check whether the code creates a separate rule for each row.
Use CellRangeAddressList to define a contiguous range and create one validation for that range instead of one per cell. Create separate rules for columns or groups that require different conditions.
Put lookup values in worksheet ranges, then use workbook.createName() to define names for those ranges. In the validation helper, use createFormulaListConstraint with the appropriate name instead of duplicating long list definitions.
Write the revised workbook with Apache POI, open it in Excel, and check Data > Data Validation on representative cells in both columns. Confirm that Excel no longer reports a repair and that the expected lists appear.

Inspect the workbook XML and isolate the affected rules
Use this approach if Excel still repairs the file after the validation rules are consolidated.
Work with Excel-compatible spreadsheets in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar spreadsheet interface. Open and edit Excel-format files as you move between applications; use Excel and Apache POI troubleshooting to resolve Excel-specific repair issues.

Frequently Asked Questions
Does having 80,000 rows alone cause Excel to remove validation?
Not necessarily. Excel worksheets support up to 1,048,576 rows. The number or structure of validation records, their references, or other generated XML may be involved; check Excel's repair log to investigate.
How can I apply the same validation to an entire range with Apache POI?
Define the target cells with CellRangeAddressList, create a constraint with the sheet's data validation helper, and add the resulting validation to the sheet. Use separate rules when cells require different conditions.
Where can I check a validation rule in Excel?
Select a representative cell and open Data > Data Validation. Check the validation type and source, then test the drop-down if the rule uses a list.
Can a named range help with validation lists?
Yes. Store the lookup values in a worksheet range, define a workbook name for it, and use that name as the list-validation source. Verify that the name and its reference are valid in the generated workbook.
What if Excel still removes the rules after I combine them?
Inspect the repair log and the affected worksheet XML inside the XLSX archive. Generate smaller test files to isolate problematic rules or references, and consider splitting the data or simplifying the lookup structure.




