Reference another spreadsheet in a formula
Posted: Mon Oct 26, 2009 4:52 pm
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...
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...