You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sheets: deleting a row or column leaves formulas pointing at whatever slid into its place #658
put 10, 20, 30 in a1:a3 and =a2 in b1. delete row 2. b1 still says =a2 and now shows 30, excel and google sheets both give #REF! here. nothing tells you the number changed which is the bad part
ranges do the same thing. 1, 2, 3, 100 in a1:a4 and =sum(a1:a3) somewhere, delete row 3 and the formula stays =sum(a1:a3) so it shows 103 instead of shrinking to a1:a2. columns have the exact same problem
cause is in adjustRef. deleteRows calls rewriteAllFormulas(at + count, -count, 0, 0) and adjustRef only shifts a ref when r >= rowAt, so a ref inside the deleted block is never touched and then rebuildSheetCells moves the next row into its spot. the return "#REF!" line in there looks like it was ment for exactly this but r cant go negative on that path so it never fires
two smaller things in the same function
every insert or delete drops the $ from every formula on the sheet becuase the ref gets rebuilt with rcToRef. =$a$12 turns into =a12 even if a1 didnt move, and thats what xlsx export writes out
in Sheet2!a1:a5 only the first end has the sheet name, so a5 gets shifted when sheet1 loses a row and it becomes Sheet2!a1:a4
repro
new sheet, a1:a3 = 10, 20, 30, b1 = =a2
select row 2, delete row(s)
b1 shows 30
i have a fix here Cintu07@5805abc3 . adjustRef now moves each edge of the span a ref bounds, an edge on a deleted line moves in to the nearest surviving line, a span with nothing left becomes #REF!, a range naming another sheet is left alone and $ is kept. its 32+/17- in client.ts so its over the 30 line limit, happy to open a pr if you want it or split the $ part out
Activity