那是因为在导出Excel后FastReport预览报表的默认路径会发生改变,变成你导出的路径,你在FastReport设置报表的界面从把你的模板新打开一下就好了。 要不然就修改Tfrxeport.LoadFromFile的源代码在unit frxClass;里 例子如下 function TfrxReport.LoadFromFile(const FileName: String; ExceptionIfNotFound: Boolean = False): Boolean; var f: TFileStream; cPath:string; cFileName:string; begin Clear; FFileName := ''; cPath:=extractFilePath(application.exename); //绝对路径 if (pos(':', FileName) > 0) then begin cFileName := FileName; end else begin cFileName:=cPath+FileName; end; Result := FileExists(cFileName); if Result or ExceptionIfNotFound then begin f := TFileStream.Create(cFileName, fmOpenRead or fmShareDenyWrite); try LoadFromStream(f); FFileName := cFileName; finally f.Free; end; end; end; 将LoadFromFile内容改成这样就没问题了。
我的FastReport版本是3.15的。
要不然就修改Tfrxeport.LoadFromFile的源代码在unit frxClass;里
例子如下
function TfrxReport.LoadFromFile(const FileName: String;
ExceptionIfNotFound: Boolean = False): Boolean;
var
f: TFileStream;
cPath:string;
cFileName:string;
begin
Clear;
FFileName := '';
cPath:=extractFilePath(application.exename);
//绝对路径
if (pos(':', FileName) > 0) then
begin
cFileName := FileName;
end
else begin
cFileName:=cPath+FileName;
end;
Result := FileExists(cFileName);
if Result or ExceptionIfNotFound then
begin
f := TFileStream.Create(cFileName, fmOpenRead or fmShareDenyWrite);
try
LoadFromStream(f);
FFileName := cFileName;
finally
f.Free;
end;
end;
end;
将LoadFromFile内容改成这样就没问题了。