Reference another spreadsheet in a formula

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
Orionizer
Posts: 5
Joined: Mon Oct 26, 2009 4:49 pm
Location: North Carolina, USA

Reference another spreadsheet in a formula

Post by Orionizer »

Is it possible to reference another spreadsheet in a formula? I've tried the following code and all I get are zeroes (no formula) in sheet '2'...

var
NewSheet: TSheet;
X: Integer;
FormStr: String;

begin
XLSRWMain.Filename:='C:\Test.xlsx';
XLSRWMain.Sheets.Clear;
NewSheet:=XLSRWMain.Sheet[0];
NewSheet.Name:='1';
for X:=1 to 10 do
begin
NewSheet.AsInteger[0,X]:=X;
end;
NewSheet:=XLSRWMain.Sheets.Add(wtSheet);
NewSheet.Name:='2';
for X:=1 to 10 do
begin
FormStr:='SUM(''1''!A' + IntToStr(X) + '*2)';
NewSheet.AsFormula[0,X]:=FormStr;
end;
XLSRWMain.Write;
end;

I have inserted a Showmessage routine to show the value of FormStr before setting the formula value in the cell and everything looks correct, but my results in the sheet titled '2' are all zeroes...
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Reference another spreadsheet in a formula

Post by larsa »

Hello

This shall be fixed in the last update. Please download it and try again.
Lars Arvidsson, Axolot Data
Orionizer
Posts: 5
Joined: Mon Oct 26, 2009 4:49 pm
Location: North Carolina, USA

Re: Reference another spreadsheet in a formula

Post by Orionizer »

Will do - thanks!
Post Reply