Repository navigation
Move references in data validation and conditional formatting formulas - #422
Merged
Merged
Conversation
shift_coordinate left the locked ($) column and row of a reference where they were, so after insert_new_row or remove_row, =SUM($H$1:$H$2), VLOOKUP(x,$A$2:$B$100,...) and =$H$4 read the wrong cells. In Excel $ only fixes a reference when a formula is copied or filled; inserting or removing cells moves it like any other. The copy path (shared formulas) uses adjustment_formula_coordinate and still keeps $ references. shared_adjustment_preserves_quoted_sheet inserts a row above E38, so its expected reference is now $E$39; the test is about the quoted sheet name.
Inserting or removing rows and columns moved the range a data validation or conditional format applies to, but not the references in its formulas, so a list validation fed from $H$1:$H$3 or a rule like $B1>$F$1 pointed at the old cells. Run formula1/formula2 and cfRule formulas through the same adjustment as cell formulas; references to other sheets are left alone.
Owner
|
@jayhemnani9910 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #417, which moves a data validation's range on row and column edits but not the references in its formulas. Conditional formatting has the same gap:
The dropdown then lists blank, blank, Red, and the rule tests the wrong row.
formula1/formula2of a data validation and thecfRuleformula are now passed through the same insert/remove adjustment as cell formulas (two small helpers inhelper/formula.rs), with the worksheet's title, soSheet1!$H$1:$H$3on Sheet1 moves too and references to other sheets stay. A literal list ("a,b,c") is left as is.Built on #421, since
$references only move with that change.Tested: new
row_edits_move_data_validation_formulasandrow_edits_move_sheet_qualified_validation_formulasfail without the change, plus unit tests for the helper (own-sheet, other-sheet, literal list);cargo testpasses. Reading an xlsx with both rules,insert_new_row(1, 2)and writing it back:<formula1>$H$3:$H$5</formula1>,<formula1>$J$3</formula1>,<formula>$B3>$F$3</formula>,<formula>$F$3</formula>.