ruilisi / fortune-sheet

A drop-in javascript spreadsheet library that provides rich features like Excel and Google Sheets
https://ruilisi.github.io/fortune-sheet-docs/
MIT License
2.54k stars 227 forks source link

Do not update merged cells when deleting a row #593

Closed ojrestrepom closed 2 months ago

ojrestrepom commented 2 months ago

Describe the bug I create a sheet with merged cells but when I delete a row located above them, the information of the new position of the row that has the merge is not updated. For example: I have this cell: { "r": 35, "c": 1, "v": { "v": "SUBTOTAL BRUTO", "m": "SUBTOTAL BRUTO", "mc": { "r": 35, "c": 1, "rs": 1, "cs": 4 }, "ff": 0, "bl": 1, "bg": "rgb(226,107,10)", "fc": "rgb(255,255,255)", "ht": 2, "ct": { "s": [] } } By deleting rows 30 through 34, the old row 35 becomes row 30. But now, the new mc component is mc: {c: 1, ​​​​​​cs: 4, r: 35, rs: 1} Although we are in position row 30 and column 1, it maintains the previous position.

It shows the following error: Unhandled Runtime Error. TypeError: can't access property 1, data[r] is undefined. imagen_2024-09-09_123937471

And it appears on the console Uncaught TypeError: can't access property 1, data[r] is undefined getCellValue index.esm.js:51174 getRealCellValue index.esm.js:51439 drawMain index.esm.js:66183 Sheet index.esm.js:4103 commitHookEffectListMount react-dom.development.js:21102 commitHookPassiveMountEffects react-dom.development.js:23154

image

To Reproduce In the following git link I leave the information with which I build the sheets. https://github.com/ojrestrepom/fortunesheet/blob/main/info.json

You can go to the second sheet called "Panama" and delete rows 31 to 35 (indexed from 30 to 34) and it will generate the error I mentioned. image

Expected behavior I would expect that deleting a row would update the information in the merged cells. This error is not generated in the version you have of the server. https://ruilisi.github.io/fortune-sheet-demo/?path=/story/features--basic

I am working with NEXT JS 14 and storing the information in MongoDB

Thank you very much.

ojrestrepom commented 2 months ago

I'm checking because I don't have the config.merge element configured. I'll be reporting if this solves the problem or not. Thank you very much

ojrestrepom commented 2 months ago

Sorry. It's now fixed. It was a matter of setting config.merge to update the merged cell information when a row is deleted. I'm sorry for any inconvenience I may have caused. Thank you very much.