Bugs. Range is not copied correctly lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- veb86 · 2024-07-03 13:36 Hello! The bug is as follows: When copying cells that contain a range of type SUM($A$1:A1), the range is broken; the output is SUM($A$1), but should be SUM($A$1:A2). If we write: SUM($A$1:A2), we get SUM($A$1:A2), but it should have been SUM($A$1:A3). The rules for copying ranges have been violated. Try copying the formulas into Excel yourself and you will see the difference in results Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     b.Options := [boReadFormulas];    b.ReadFromFile('d:\test1\start.xlsx', sfOOXML);    sh := b.GetFirstWorksheet;      sh.CopyCell(0,1,1,1,b.GetFirstWorksheet);  sh.CopyCell(0,2,1,2,b.GetFirstWorksheet);    sh.CopyCell(0,3,1,3,b.GetFirstWorksheet);        sh.CalcFormulas;     b.WriteToFile('d:\test1\res.xlsx', sfOOXML, true); ---------------------------------------------------------------------- wp · 2024-07-04 17:13 Please test the new commit in ccr. ---------------------------------------------------------------------- veb86 · 2024-07-05 06:22 Quote from: wp on July 04, 2024, 07:13:33 pmPlease test the new commit in ccr. I immediately see the bug. Cell C1 - SUM($A$1:A1), after saving it became SUM($A$1) In the XML file (4.xlsx) the entry for this cell is as follows: SUM($A$1:A1)1 This bug has no problems in working correctly, but this bug would be better fixed. It can ruin an existing Excel file and the ability to correctly copy cells will disappear. I'll keep testing. I'll prepare my code for larger calculations soon. Thank you very much for fixing the bugs!!! ---------------------------------------------------------------------- wp · 2024-07-05 11:07 Found code in regeneration of string formula by parser which collapses a cell range to a single cell when both range ends are equal (A1:A1 --> A1). Fix might have side-effects somewhere, unit tests do not detect anything, though. ---------------------------------------------------------------------- Zvoni · 2024-07-05 12:16 Quote from: wp on July 05, 2024, 01:07:36 pmFound code in regeneration of string formula by parser which collapses a cell range to a single cell when both range ends are equal (A1:A1 --> A1). Fix might have side-effects somewhere, unit tests do not detect anything, though. Having not tested anything: Did you account for a Range like "A:A" (Whole column A)? and in TS special case: Range("$A$1:A1") <> Range("A1:A1") ---------------------------------------------------------------------- veb86 · 2024-07-05 12:50 Quote from: wp on July 05, 2024, 01:07:36 pmFound code in regeneration of string formula by parser which collapses a cell range to a single cell when both range ends are equal (A1:A1 --> A1). Fix might have side-effects somewhere, unit tests do not detect anything, though. I'll keep it on mind. In any case, when bugs are discovered, I will write about it ---------------------------------------------------------------------- wp · 2024-07-05 16:13 I don't know ATM how difficult it is to extend the formula parser so that it can deal with a column or row range alone, but I don't have plans to implement this. It was never the intention for fpspreadsheet to be able to emulate all of Excel/Calc. ---------------------------------------------------------------------- wp · 2024-07-05 16:24 Quote from: veb86 on July 05, 2024, 08:22:49 amI'll keep testing. It would be helpful if you could add your tests to the fpspreadsheet unit tests in folder unit-tests/common of the fpspreadsheet installation. Even (or better: in particular) trivial tests are welcome. The cell-copy tests are in unit copytests. I took the freedom to add your recent range tests (procedure CopyFormulasWithAbsRelRanges). Run application spreadtestgui (spreadtestcli should work as well, but I do not update it regularly). Send patch files or the test procedures ready to copy into the test suite. ---------------------------------------------------------------------- veb86 · 2024-07-05 19:01 Quote from: wp on July 05, 2024, 06:24:58 pmIt would be helpful if you could add your tests to the fpspreadsheet unit tests in folder unit- tests/common of the fpspreadsheet installation. Even (or better: in particular) trivial tests are welcome. The cell-copy tests are in unit copytests. I took the freedom to add your recent range tests (procedure CopyFormulasWithAbsRelRanges). Run application spreadtestgui (spreadtestcli should work as well, but I do not update it regularly). Send patch files or the test procedures ready to copy into the test suite. Next time I'll try adding a test, but based on your commit it's not easy. ---------------------------------------------------------------------- wp · 2024-07-05 20:52 Don't try too hard, it's good already when you post here your code and test files like before.