writing signed float to excel

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
folocco
Posts: 5
Joined: Mon Nov 06, 2017 4:25 pm

writing signed float to excel

Post by folocco »

Hi

if i use XLS.SheetByName('Legenda').AsFloat[cc,ct] to write the string '-2.03' it tells me that isn't a float.
What i have to use in delphi in ordrer to write a signed number?if i use .asString or .asVariant Excel tells me that is a number written as a text and isn't good for me cause i wanna a signed number.
Thank you
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: writing signed float to excel

Post by larsa »

Hello

There is no method in the component for parsing strings as numbers, but you can easily create one yourself:

Code: Select all

var
  S: string;
  N: double ;
begin
  S := '-2.03';
  if TryStrToFloat(S,N) then
    XLS[0].AsFloat[1,1] := N
  else
    XLS[0].AsFloat[1,1] := S;
end;
Lars Arvidsson, Axolot Data
Post Reply