function TXLSNames.Add bug

Questions and answers on how to use XLSReadWriteII 3/4/5.

function TXLSNames.Add bug

Postby Moisha » Thu Feb 16, 2017 7:18 am

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
Moisha
 
Posts: 7
Joined: Wed Apr 06, 2016 1:00 pm

Re: function TXLSNames.Add bug

Postby larsa » Sat Feb 18, 2017 4:34 pm

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.
Lars Arvidsson, Axolot Data
larsa
Site Admin
 
Posts: 581
Joined: Mon Jun 27, 2005 9:30 pm

Re: function TXLSNames.Add bug

Postby Moisha » Mon Feb 27, 2017 12:12 pm

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.
Moisha
 
Posts: 7
Joined: Wed Apr 06, 2016 1:00 pm

Re: function TXLSNames.Add bug

Postby larsa » Tue Feb 28, 2017 1:37 pm

Hello

The code works fine here. Tested wit version 6.00.07
Lars Arvidsson, Axolot Data
larsa
Site Admin
 
Posts: 581
Joined: Mon Jun 27, 2005 9:30 pm

Re: function TXLSNames.Add bug

Postby Moisha » Thu Mar 02, 2017 12:30 pm

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.
Moisha
 
Posts: 7
Joined: Wed Apr 06, 2016 1:00 pm

Re: function TXLSNames.Add bug

Postby larsa » Thu Mar 02, 2017 6:12 pm

Hello

Sorry, but we only supports the latest version (now version 6).
Lars Arvidsson, Axolot Data
larsa
Site Admin
 
Posts: 581
Joined: Mon Jun 27, 2005 9:30 pm


Return to XLSReadWriteII 3/4/5

Who is online

Users browsing this forum: No registered users and 1 guest

cron