Page 1 of 1

function TXLSNames.Add bug

Posted: Thu Feb 16, 2017 7:18 am
by Moisha
hi.
Here is function text

Code: Select all

function TXLSNames.Add(const AName, ASheetName: AxUCString; const ACol, ARow: integer): TXLSName;
var
  Def: AxUCString;
begin
  if FManager.Worksheets.Find(ASheetName) < 0 then begin
    FManager.Errors.Error(ASheetName,XLSERR_FMLA_UNKNOWNSHEET);
    Result := Nil;
  end
  else begin
    Def := ASheetName+ '!' + ColRowToRefStr(ACol,ARow,True,True);
    Result := Add(AName,Def);
  end;
end;
Problem occurs if ASheetName has special symbol i.e. "one-two"
Tokenizer breaks sheet name on this symbol and can not find sheet with name "one".
Quoting sheet name is not an option because

Code: Select all

FManager.Worksheets.Find(ASheetName)
does not check quotes and can not find sheet with quoted name.

i suggest to fix function in this way:

Code: Select all

Def := QuotedStr(ASheetName)+ '!' + ColRowToRefStr(ACol,ARow,True,True);
regards
Anton

Re: function TXLSNames.Add bug

Posted: Sat Feb 18, 2017 4:34 pm
by larsa
Hello

Sheet names with special characters in Names and formulas shall be quoted with single quotes.

Regarding the rest, please give me a code sample on what is not working.

Re: function TXLSNames.Add bug

Posted: Mon Feb 27, 2017 12:12 pm
by Moisha
Here is code generating described error.

Code: Select all

program AddNameErr;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  XLSSheetData5,
  XLSReadWriteII5;

var xls: TXLSReadWriteII5;
    sheet: TXLSWorksheet;

begin
  xls := TXLSReadWriteII5.Create(nil);
  sheet := xls.Add();
  sheet.Name := 'one two';
  try
    xls.Names.Add('name1', sheet.name, 1, 1);
  except
    // Project AddNameErr.exe raised exception class Exception with message 'E4016: Uknown sheet name "two"'.
  end;

  try
    xls.Names.Add('name1', QuotedStr(sheet.name), 1, 1);
  except
    // quoting does not help
    // Project AddNameErr.exe raised exception class Exception with message 'E4016: Uknown sheet name "'one two'"'.
  end;
end.
Suggested corrections fix it and user has no need to quote sheet name.

Re: function TXLSNames.Add bug

Posted: Tue Feb 28, 2017 1:37 pm
by larsa
Hello

The code works fine here. Tested wit version 6.00.07

Re: function TXLSNames.Add bug

Posted: Thu Mar 02, 2017 12:30 pm
by Moisha
Hi.

Code fails on last XLSReadWriteII 5 for XE4 from http://www.axolot.com/components/f_downloadreg.htm.
Is version 5 supported or it is nessessary to buy version 6 for further support?

Regards.
Anton.

Re: function TXLSNames.Add bug

Posted: Thu Mar 02, 2017 6:12 pm
by larsa
Hello

Sorry, but we only supports the latest version (now version 6).