Recent

Author Topic: InsertRow changes other worksheets too  (Read 418 times)

jollytall

  • Full Member
  • ***
  • Posts: 214
InsertRow changes other worksheets too
« on: April 19, 2022, 10:45:48 am »
wp, I came across the following problem:
Code: Pascal  [Select][+][-]
  1. var
  2.   WB : TsWorkbook;
  3.   WS, WS2 : TsWorksheet;
  4. begin
  5. WB := TsWorkbook.Create;
  6. WB.Options := [boReadFormulas, boCalcBeforeSaving, boAutoCalc];
  7. WS := WB.AddWorksheet('test');
  8. WS.WriteNumber(5, 0, 10);
  9. WS.WriteFormula(0, 0,'A6');
  10. writeln('before ',WS.ReadAsNumber(0, 0));
  11. WS2 := WB.AddWorksheet('test2');
  12. WS2.WriteNumber(5, 0, 10);
  13. WS2.WriteFormula(0, 0,'A6');
  14. WS2.InsertRow(2);
  15. writeln('after ',WS.ReadAsNumber(0, 0), ' ', WS2.ReadAsNumber(0, 0));
  16. WB.WriteToFile('test.ods', true);
  17. WB.Free;
  18. readln;
  19. end.
  20.  
When I insert a row in WS2 it changes the formulas in other Worksheets too. It can also be seen in the dump.
Is it a bug, or I do something wrong?

wp

  • Hero Member
  • *****
  • Posts: 10281
Re: InsertRow changes other worksheets too
« Reply #1 on: April 21, 2022, 06:59:55 pm »
The new version on CCR fixes this issue. I added a variety of test cases covering also the similar operations of inserting columns and inserting/deleting rows/columns.
« Last Edit: April 21, 2022, 10:32:37 pm by wp »

jollytall

  • Full Member
  • ***
  • Posts: 214
Re: InsertRow changes other worksheets too
« Reply #2 on: April 22, 2022, 08:08:46 am »
Thanks, it works in my use case. I did not test all other cases, but guess those also work.

 

TinyPortal © 2005-2018