Recent

Author Topic: Why there is no formula for opening a file  (Read 268 times)

dodgex

  • New Member
  • *
  • Posts: 14
Why there is no formula for opening a file
« on: January 09, 2026, 09:33:57 am »
  try
    sWorkbook := TsWorkbook.Create;
    sWorkbook.ReadFromFile(decPath);
    sWorksheet := sWorkbook.GetWorksheetByIndex(0);

    // do somethings......
   
    sWorkbook.WriteToFile(decPath, True);
    LCLIntf.OpenDocument( decPath );
  finally
    sWorkbook.free;
  end;

After writing data to excel, the original formula set in “ sWorkbook.WriteToFile(decPath, True)” will disappear;why??

wp

  • Hero Member
  • *****
  • Posts: 13332
Re: Why there is no formula for opening a file
« Reply #1 on: January 09, 2026, 10:23:59 am »
Since fpspreadsheet does not support all formulas to be found in spreadsheet files, reading of formulas is turned off by default. In order to activate it, add boReadFormulas to the workbook options before reading (and probably also boAutoCalc to automatically update calculated cells when cell content changes).
Code: Pascal  [Select][+][-]
  1.   sWorkbook := TsWorkbook.Create;
  2.   sWorkbook.Options := sWorkbook.Options + [boReadFormulas, boAutoCalc];
  3.   sWorkbook.ReadFromFile(decPath);
  4.   ...
« Last Edit: January 09, 2026, 03:46:55 pm by wp »

dodgex

  • New Member
  • *
  • Posts: 14
Re: Why there is no formula for opening a file
« Reply #2 on: January 12, 2026, 02:56:29 am »
Since fpspreadsheet does not support all formulas to be found in spreadsheet files, reading of formulas is turned off by default. In order to activate it, add boReadFormulas to the workbook options before reading (and probably also boAutoCalc to automatically update calculated cells when cell content changes).
Code: Pascal  [Select][+][-]
  1.   sWorkbook := TsWorkbook.Create;
  2.   sWorkbook.Options := sWorkbook.Options + [boReadFormulas, boAutoCalc];
  3.   sWorkbook.ReadFromFile(decPath);
  4.   ...


Thank you!!
I have another question to consult. I have set zero values not to be displayed in the EXCEL template. Why does this setting disappear when I open EXCEL

 

TinyPortal © 2005-2018