You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fesod.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/10/20 10:27:31 UTC

[PR] fix: shift template dropdown regions with inserted rows [fesod]

Aias00 opened a new pull request, #1245:
URL: https://github.com/apache/fesod/pull/1245

   ## Purpose of the pull request
   
   Closed: #226
   
   When `forceNewRow(true)` expands a template list, cell content moves but the data-validation regions behind dropdowns stay at their old rows. In the regression fixture, repeated fills move the footer from row index 4 to 6 while its dropdown remains at 4.
   
   ## What's changed?
   
   - Move validation target regions below the insertion point and extend regions crossing it, for both XLSX XML validations and XLS BIFF validation records.
   - Preserve the validation constraints, prompt/error settings and column positions. Constraint formula contents are unchanged.
   - Move validations even when their cells are below the final physical template row. Keep whole-column regions within the format's row limit; reject ranges pushed entirely past that limit.
   - Add public fill/write/reopen regression tests for XLS and XLSX, repeated fills, unaffected regions, crossing and whole-column ranges, and fills that do not insert rows.
   
   ### Validation
   
   The regression fails on the base commit for both XLS and XLSX: expected first validation row 6, actual 4.
   
   ```sh
   ./mvnw -B -pl fesod-common,fesod-shaded,fesod-sheet -Dtest=FillDataValidationTest,FillDataTest -Dsurefire.failIfNoSpecifiedTests=false package
   ./mvnw -B -pl fesod-common,fesod-shaded,fesod-sheet -Dtest.excludedGroups=fuzz package
   ./mvnw -B -pl fesod-sheet spotless:check
   ```
   
   Focused tests: 17 passed. Full `fesod-sheet` suite excluding fuzz: 1727 passed, no failures or errors. Spotless passed.
   
   ## Checklist
   
   - [x] I have read the [Contributor Guide](https://fesod.apache.org/community/contribution/).
   - [x] I have written the necessary doc or comment.
   - [x] I have added the necessary unit tests and all cases have passed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org


Re: [PR] fix: shift template dropdown regions with inserted rows [fesod]

Posted by "skytin1004 (via GitHub)" <gi...@apache.org>.
skytin1004 commented on code in PR #1245:
URL: https://github.com/apache/fesod/pull/1245#discussion_r4343323126


##########
fesod-sheet/src/main/java/org/apache/fesod/sheet/write/executor/ExcelWriteFillExecutor.java:
##########
@@ -187,13 +191,64 @@ private void shiftRows(int size, List<AnalysisCell> analysisCellList) {
         if (number <= 0) {
             return;
         }
-        sheet.shiftRows(maxRowIndex + 1, lastRowIndex, number, true, false);
+        if (maxRowIndex < lastRowIndex) {
+            sheet.shiftRows(maxRowIndex + 1, lastRowIndex, number, true, false);
+        }
+        shiftDataValidationRanges(sheet, maxRowIndex, number);
 
         // The current data is greater than unity rowindex increase
         increaseRowIndex(templateAnalysisCache, number, maxRowIndex);
         increaseRowIndex(templateCollectionAnalysisCache, number, maxRowIndex);
     }
 
+    private void shiftDataValidationRanges(Sheet sheet, int afterRow, int number) {
+        int lastRow = sheet.getWorkbook().getSpreadsheetVersion().getLastRowIndex();
+        if (sheet instanceof XSSFSheet) {
+            XSSFSheet xssfSheet = (XSSFSheet) sheet;
+            if (!xssfSheet.getCTWorksheet().isSetDataValidations()) {
+                return;
+            }
+            for (CTDataValidation validation :
+                    xssfSheet.getCTWorksheet().getDataValidations().getDataValidationList()) {
+                List<String> shifted = new ArrayList<>();
+                for (Object reference : validation.getSqref()) {
+                    CellRangeAddress range = CellRangeAddress.valueOf(reference.toString());
+                    shiftDataValidationRange(range, afterRow, number, lastRow);
+                    shifted.add(range.formatAsString());
+                }
+                validation.setSqref(shifted);

Review Comment:
   Hi @Aias00, thanks for working on this.
   
   I tested a formula-backed dropdown with a real XLSX file. After `forceNewRow(true)`, the validation region moved from B5 to B6, but its source formula stayed at `$E$5:$E$6` while the source values moved to E6:E7.
   
   Could you please shift `formula1` and `formula2` with the same row movement and cover this with an XLSX save/reopen test? Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org