Recent

Author Topic: Add the autocalchangedwithoutcalcformulas property in TsWorkbookSource.  (Read 382 times)

abcthing

  • New Member
  • *
  • Posts: 19
In my application, do not recalculate when load file and autocalc is true.
Code: Pascal  [Select][+][-]
  1.  
  2.   AWorksheetGrid.AutoCalc:=false;
  3.   AWorksheetGrid.WorkbookSource.LoadFromSpreadsheetFile(AFileName);
  4.   AWorksheetGrid.AutoCalc:=true;
  5.  

So I want to add the autocalchangedwithoutcalcformulas property in TsWorkbookSource.
Code: Pascal  [Select][+][-]
  1.   TsWorkbookSource = class(TComponent)
  2.   private
  3.     FAutoCalcChangedWithoutCalcFormulas: boolean; //add
  4.   published
  5.     property AutoCalcChangedWithoutCalcFormulas: boolean read FAutoCalcChangedWithoutCalcFormulas write FAutoCalcChangedWithoutCalcFormulas default False;  //add
  6.   end;
  7.  
  8. procedure TsWorkbookSource.SetOptions(AValue: TsWorkbookOptions);
  9. .......
  10. begin
  11.     .......
  12.     if AutoCalcChanged and (boAutoCalc in FOptions) then
  13.       if not FAutoCalcChangedWithoutCalcFormulas then  //add
  14.         Workbook.CalcFormulas;
  15.   end;
  16. end;
  17.  

wp

  • Hero Member
  • *****
  • Posts: 7737
Re: Add the autocalchangedwithoutcalcformulas property in TsWorkbookSource.
« Reply #1 on: October 16, 2020, 12:26:37 pm »
This option is a bit hard to understand.

What is your primary concern? Do you want to load a file without calculating formulas, for example because the formulas already have been calculated by the source application? And later you want to have AutoCalc active, but you don't want to calculate the formulas again when AutoCalc becomes true.

Is your workbook loaded with so many formulas that recalculation takes a noticeable time? In this case you should consider to use another library because fpspreadsheet is not optimized for calcuilation speed.

Would it be ok to have an option boCalcAfterLoading which is on by default, but you could turn it off? Since AutoCalc is on by default you would not have to turn it on again and thus avoid the recalculation. boCalcAfterLoading would be a natural extension of the current workbook options where a boCalcBeforeSaving already exists.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

abcthing

  • New Member
  • *
  • Posts: 19
Re: Add the autocalchangedwithoutcalcformulas property in TsWorkbookSource.
« Reply #2 on: October 16, 2020, 03:43:27 pm »
Yes, boAutoCalc is exactly what I need.
Thank you very much for solved my problem!

Because I use user-defined-formulas and this formula will connect to the server,
I don't want the login dialog to appear when the program starting.
« Last Edit: October 16, 2020, 04:02:05 pm by abcthing »

wp

  • Hero Member
  • *****
  • Posts: 7737
Re: Add the autocalchangedwithoutcalcformulas property in TsWorkbookSource.
« Reply #3 on: October 16, 2020, 05:02:18 pm »
So, you mean there is nothing to be done for me?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

abcthing

  • New Member
  • *
  • Posts: 19
Re: Add the autocalchangedwithoutcalcformulas property in TsWorkbookSource.
« Reply #4 on: October 17, 2020, 02:48:04 pm »
Sorry, I made a mistake when debug yesterday.

I need boCalcAfterLoading, please add it.
« Last Edit: October 17, 2020, 02:59:10 pm by abcthing »

 

TinyPortal © 2005-2018