Formulas fails when <CR> inside

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
Moisha
Posts: 18
Joined: Wed Apr 06, 2016 1:00 pm

Formulas fails when <CR> inside

Post 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
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Formulas fails when <CR> inside

Post 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.
Lars Arvidsson, Axolot Data
Post Reply