Recent

Author Topic: Problem in writing formulas (dash)  (Read 608 times)

veb86

  • Jr. Member
  • **
  • Posts: 85
Problem in writing formulas (dash)
« on: January 17, 2025, 06:26:52 am »
Hello. Happy New Year and Merry Christmas!
There is a problem with the formula entry. See the example
The library does everything correctly, but when you open the file in Excel, you can see that another formula has been written to the cell.
The apostrophes are not placed correctly.
It should:
'ЩР-1'!B2
But it was written:
ЩР-'1'!B2

If you remove the dash from the name, everything works. Now I try not to use dashes when working, but this is a bug and it would be great to fix it

wp

  • Hero Member
  • *****
  • Posts: 12597
Re: Problem in writing formulas (dash)
« Reply #1 on: January 17, 2025, 06:16:53 pm »
In fpsUtils, replace function "SheetNameNeedsQuotes" by this, and report back:

Code: Pascal  [Select][+][-]
  1. function SheetNameNeedsQuotes(ASheet: String): Boolean;
  2. const
  3.   FORMULA_CHARS = ['+', '-', '*', '/', '^'];
  4. var
  5.   i: Integer;
  6. begin
  7.   if ASheet <> '' then begin
  8.     Result := true;
  9.     if (ASheet[1] in (['0'..'9', '.'] + FORMULA_CHARS)) then exit;
  10.     for i := 1 to Length(ASheet) do
  11.       if (ASheet[i] in ([' ', '<', '>', '='] + FORMULA_CHARS)) then exit;
  12.   end;
  13.   Result := false;
  14. end;

veb86

  • Jr. Member
  • **
  • Posts: 85
Re: Problem in writing formulas (dash)
« Reply #2 on: January 18, 2025, 12:12:00 pm »
I checked, everything works! If there are any problems, I will write

 

TinyPortal © 2005-2018