Page 1 of 1

Formulas fails when <CR> inside

Posted: Tue Feb 20, 2018 11:29 am
by Moisha
The problem is easy to reproduce

Code: Select all

xls := TXLSReadWriteII5.Create(nil);
xls[0].AsFormula[1, 1] := 'IF(A1="";'#13'"1";"0")';
Code fails and memory leak present: TXLSTokenizerList is not destroed.

MS Excel has no problems parsing such expressions.
I suggest the next improvement in file XLSTokenizer5.pas:

Code: Select all

procedure TXLSTokenizer.EatWhitespaces;
begin
  while CharInSet(CurrChar, Xc12Chr_WhitespaceChars) do // instead of CurrChar = Xc12Chr_Space
    Eat;
end;
Regadrs
Moisha

Re: Formulas fails when <CR> inside

Posted: Thu Feb 22, 2018 11:55 am
by larsa
Hello

There is a reason (that I don't remember) why EatWhitespaces only checks for space characters so the code will not be changed. CR in formulas is such an unusual thing so I don't think this is a big problem.