Fastreport error designer

Asked

Viewed 1,085 times

1

I want to create a report generator on my system, allowing the user to customize the layout of the report.

I need to save these reports on banco de dados so that it is accessible to all computers in the network.
(no way with shared folder)

When I do LoadFromFile or LoadFromStream this giving Exceptions Eaccessviolation and/or Invalid floating point Operation

Code:

procedure TForm2.FormCreate(Sender: TObject);
    begin
      frxReport1.DesignReportInPanel(Panel1);
      frxReport1.DataSets.Clear;
    end;

{relatorio <-> arquivo}
procedure TForm2.LoadfromFile1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
  begin
    frxReport1.Clear;
    frxReport1.DataSets.Clear;
    frxReport1.LoadFromFile(OpenDialog1.FileName);
    frxReport1.Designer.Update;
    frxReport1.Designer.UpdatePage;
    frxReport1.Designer.UpdateControlState;
  end;
end;

procedure TForm2.gravar1Click(Sender: TObject);
begin
  if SaveDialog1.Execute then
    frxReport1.SaveToFile(SaveDialog1.FileName);
end;

{relatório <-> DB}
procedure TForm2.mniLoadfromDB1Click(Sender: TObject);
var
  ms: TStringStream;
begin
  if not ZConnection1.Connected then
    ZConnection1.Connect;
  sds1.Close;
  sds1.Open;
  sds2.Close;
  sds2.ParamByName('id').AsInteger := sds1ID_GRELATORIO.AsInteger;
  sds2.Open;
  frxReport1.Clear;
  pFinalizaDatasets;
  //O Field report deve ser convertido para String pois o zeos retorna
  // Blob como TWideMemoField o que causa erro se transferimos diretamente para stream
  frxReport1.LoadFromStream(TStringStream.Create(sds1REPORT.AsString));
  //frxReport1.DesignReportInPanel(Panel1);

  //frxReport1.DataSets.Clear;
  //sds2.First;
  //while not sds2.Eof do
  //begin
  //  pAddDataSet(sds2NOME.AsString,sds2COMANDO_SQL.AsString);
  //  sds2.Next;
  //end;
  frxReport1.Designer.Update;
  frxReport1.Designer.UpdatePage;
  frxReport1.Designer.UpdateControlState;
  frxReport1.Designer.UpdateDataTree;
end;



procedure TForm2.pFinalizaDatasets;
var
  I: Integer;
begin
  for I := 0 to frxReport1.DataSets.Count - 1 do
  begin
    if Assigned(frxReport1.DataSets[i].DataSet)
      and (TfrxDBDataset(frxReport1.DataSets[i].DataSet).DataSet is TZReadOnlyQuery )then
    begin
      TZReadOnlyQuery(TfrxDBDataset(frxReport1.DataSets[i].DataSet).DataSet).Close;
      TfrxDBDataset(frxReport1.DataSets[i].DataSet).DataSet.Free;
      TfrxDBDataset(frxReport1.DataSets[i].DataSet).Free;
    end;
  end;
  frxReport1.DataSets.Clear;

end;

procedure TForm2.mnisavefromdb1Click(Sender: TObject);
var
  ms: TMemoryStream;
  I: Integer;
begin
  if not ZConnection1.Connected then
    ZConnection1.Connect;
  sds1.Close;
  sds1.Open;
  sds2.Close;
  sds2.Open;
  ms := TMemoryStream.Create;

  sds1.Insert;
  sds1NOME.AsString := Text;
  frxReport1.SaveToStream(ms);
  ms.Position := 0;
  sds1REPORT.LoadFromStream(ms);
  sds1FK_CATEGORIA.AsInteger := 1;
  sds1.Post;

  for I := 0 to frxReport1.DataSets.Count - 1 do
  begin
    sds2.Insert;
    sds2NOME.AsString := TfrxDBDataset(frxReport1.DataSets[i].DataSet).UserName;
    sds2COMANDO_SQL.AsString :=
      tzreadonlyquery(TfrxDBDataset(frxReport1.DataSets[i].DataSet).dataset).sql.text;
    sds2FK_GRELATORIO.AsInteger := sds1ID_GRELATORIO.AsInteger;
    sds2.Post;
  end;
  ms.Free;

end;

Fastreport function that raises exception:

function TfrxPaperXProperty.GetValue: String;
var
  e: Extended;
begin
  e := GetFloatValue;
  case TfrxDesignerForm(Designer).Units of
    duCM: e := e / 10;
    duInches: e := e / 25.4;
    duPixels: e := e * 96 / 25.4;
    duChars: e := e * 96 / 25.4 / FRatio;
  end;

  if e = Int(e) then
  Result := FloatToStr(e) else
  Result := Format('%f', [e]);

end;

Report from madException:

registered owner   : infra / Microsoft
operating system   : Windows 7 x64 Service Pack 1 build 7601
system language    : Portuguese
system up time     : 6 days 3 hours
program up time    : 3 seconds
processors         : 4x Intel(R) Core(TM) i5-4440S CPU @ 2.80GHz
physical memory    : 4176/8109 MB (free/total)
free disk space    : (C:) 610,11 GB
display mode       : 1440x900, 32 bit
process id         : $1b38
allocated memory   : 71,96 MB
largest free block : 1,08 GB
executable         : prjTeste.exe
exec. date/time    : 2015-12-24 11:35
compiled with      : Delphi 2009
madExcept version  : 4.0.12
callstack crc      : $0134efd3, $cd3301a9, $cd3301a9
exception number   : 1
exception class    : EAccessViolation
exception message  : Access violation at address 005DBDDF in module 'prjTeste.exe'. Read of address 0000003C.

main thread ($1538):
005dbddf +02b prjTeste.exe frxClass        4629  +8 TfrxComponent.GetReport
00627b07 +01b prjTeste.exe frxDesgnEditors  891  +2 TfrxDataSetProperty.GetValue
005fe3dd +019 prjTeste.exe frxInsp          486  +1 TfrxObjectInspector.GetValue
005ff5ae +0f6 prjTeste.exe frxInsp          958 +24 TfrxObjectInspector.PBMouseMove
00511891 +025 prjTeste.exe Controls                 TControl.MouseMove
0051190e +06e prjTeste.exe Controls                 TControl.WMMouseMove
00511012 +2d2 prjTeste.exe Controls                 TControl.WndProc
00510c38 +024 prjTeste.exe Controls                 TControl.Perform
00514d2a +0ae prjTeste.exe Controls                 GetControlAtPos
00514df2 +0a6 prjTeste.exe Controls                 TWinControl.ControlAtPos
00510c38 +024 prjTeste.exe Controls                 TControl.Perform
00514ea7 +097 prjTeste.exe Controls                 TWinControl.IsControlMouseMsg
005153c2 +3be prjTeste.exe Controls                 TWinControl.WndProc
00514c30 +02c prjTeste.exe Controls                 TWinControl.MainWndProc
00499300 +014 prjTeste.exe Classes                  StdWndProc
76ea7895 +00a USER32.dll                            DispatchMessageW
0053351d +11d prjTeste.exe Forms                    TApplication.ProcessMessage
00533562 +00a prjTeste.exe Forms                    TApplication.HandleMessage
0053388d +0c9 prjTeste.exe Forms                    TApplication.Run
00797531 +049 prjTeste.exe prjTeste          18  +4 initialization
76553378 +010 kernel32.dll                          BaseThreadInitThunk

--------------------------------------------------------------------------

registered owner   : infra / Microsoft
operating system   : Windows 7 x64 Service Pack 1 build 7601
system language    : Portuguese
system up time     : 6 days 3 hours
program up time    : 12 seconds
processors         : 4x Intel(R) Core(TM) i5-4440S CPU @ 2.80GHz
physical memory    : 4123/8109 MB (free/total)
free disk space    : (C:) 610,11 GB
display mode       : 1440x900, 32 bit
process id         : $2344
allocated memory   : 86,75 MB
largest free block : 805,31 MB
executable         : prjTeste.exe
exec. date/time    : 2015-12-24 11:35
compiled with      : Delphi 2009
madExcept version  : 4.0.12
callstack crc      : $2f0c432c, $4c6dd36f, $4c6dd36f
exception number   : 1
exception class    : EAccessViolation
exception message  : Access violation at address 006279C1 in module 'prjTeste.exe'. Read of address 6E04ECC6.

main thread ($2008):
006279c1 +00d prjTeste.exe frxDesgnEditors 845  +2 TfrxPictureProperty.GetValue
005fe3dd +019 prjTeste.exe frxInsp         486  +1 TfrxObjectInspector.GetValue
005ff5ae +0f6 prjTeste.exe frxInsp         958 +24 TfrxObjectInspector.PBMouseMove
00511891 +025 prjTeste.exe Controls                TControl.MouseMove
0051190e +06e prjTeste.exe Controls                TControl.WMMouseMove
00511012 +2d2 prjTeste.exe Controls                TControl.WndProc
00510c38 +024 prjTeste.exe Controls                TControl.Perform
00514d2a +0ae prjTeste.exe Controls                GetControlAtPos
00514df2 +0a6 prjTeste.exe Controls                TWinControl.ControlAtPos
00510c38 +024 prjTeste.exe Controls                TControl.Perform
00514ea7 +097 prjTeste.exe Controls                TWinControl.IsControlMouseMsg
005153c2 +3be prjTeste.exe Controls                TWinControl.WndProc
00514c30 +02c prjTeste.exe Controls                TWinControl.MainWndProc
00499300 +014 prjTeste.exe Classes                 StdWndProc
76ea7895 +00a USER32.dll                           DispatchMessageW
0053351d +11d prjTeste.exe Forms                   TApplication.ProcessMessage
00533562 +00a prjTeste.exe Forms                   TApplication.HandleMessage
0053388d +0c9 prjTeste.exe Forms                   TApplication.Run
00797531 +049 prjTeste.exe prjTeste         18  +4 initialization
76553378 +010 kernel32.dll                         BaseThreadInitThunk

1 answer

0

After calling the report through "Loadfromfile", you do not need to call "Update", just call "Designreport" to open the report layout.

I’ve used Fastreport as a user report builder for 10 years and it’s always worked perfectly.

I hope I’ve helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.