Quick reports without a database

I used Report Builder for several years, but I'm tired of cha -ching, cha -ching. This is a great reporting tool for "no database" reports.

I started playing with Fast Reports, and I am completely excited about it. This is a great reporting tool for databases, but a big question mark for complex "no database" reports. Their demos and help are terrible.

I would like to show the report I'm talking about. The report is a serial communication report that contains information about the operating system, which, of course, is of a single character. It has 4 different tables in which serial ports and tables of USB-serial devices are installed. It also has a summary note.

Has anyone successfully developed a report on the above configuration in Fast Reports? And yes, I posted the same query with Fast Reports. I just want other opinions.

Thanks in advance.

+6
source share
4 answers

I have expanded the option provided by @jrodenhi's answer, which seems to be the right way to do what you want (so I made this answer on the community wiki). So, here are two options you can use (and I think there will be more):

1. Definition of user variables

@Jrodenhi's answer shows how to add report variables to code. I will try to show here how to define them in the report designer.

  • Open Report Designer
  • Go to the menu Report / Variables ...
  • In the "Edit Variables" window, create a new category by clicking on the "Category" button. Then you can rename the category just like you, for example. for files in Windows Explorer: enter image description here

  • Then you can declare a custom variable by clicking the "Variable" button. You can give a variable some meaningful name just like you, for example. for files in Windows Explorer: enter image description here

  • After that, save the changes by clicking the "OK" button: enter image description here

  • Then you will return to the report designer, where you can find the variables just declared on the tab "Tree of the data tree" Variables from which you can drag the variables into the report: enter image description here

  • After clarifying the positions and properties of the components, you can close the report designer and return to the Delphi development environment. There you can write a handler for the OnGetValue event of your report, and if its VarName parameter is equal to your variable, change its Value parameter to the value that you want to provide to the corresponding report component:

 procedure TForm1.frxReport1GetValue(const VarName: string; var Value: Variant); begin if VarName = 'MyVariable' then Value := 'This is a new value!'; end; 

2. Change report components directly from Delphi code

It is possible to directly access report components from your Delphi code. For example, to find a specific report component by name, you can use the TfrxReport method of the TfrxReport object. Then you can follow the usual checkout scheme if the returned link is of the type of control you want to access, and if so, you can access the instance by typing, as usual.

For example, to find the TfrxMemoView object named Memo1 in the report frxReport1 and change its text, you can write:

 var Component: TfrxComponent; begin Component := frxReport1.FindObject('Memo1'); if Component is TfrxMemoView then TfrxMemoView(Component).Memo.Text := 'New text'; end; 
+8
source

Most of the reports that I write relate to payroll. In addition to the tabular data that makes up the bulk of the report, there is usually a significant amount of singular data, such as information about users and employers, which are often most easily entered as a series of variables taken from the filter dialog that runs before the report. After starting the filter, I repeat all its variables and add them to the report variables. Maybe you can pick up your singular system variables and do the same.

This is my routine, which is performed immediately before the preparation of the report. It not only adds variables, but also adds functions defined in Delphi that can be used in the report:

 procedure TFastReportDriver.SetVariables(sVariables: String; var frxReport: TfrxReport); var i, iDetail: Integer; sl: TStringList; sVariable, sValue: String; begin sl := TStringList.Create; sl.CommaText := sVariables; frxReport.Variables.Clear; frxReport.Variables[' Filter'] := Null; for i := 0 to sl.Count - 1 do begin sVariable := sl.Names[i]; sValue := Qtd(sl.ValueFromIndex[i]); frxReport.Variables.AddVariable('Filter', sVariable, sValue); end; frxReport.AddFunction('procedure CreateCheck(hPaystub, iCheckNo: Integer)'); frxReport.AddFunction('function NumberToWords(cAmount: Currency): String'); frxReport.OnUserFunction := repChecksUserFunction; sl.Free; end; 

Then in your code you call frxReport.DesignReport and at runtime you can drag and drop variables into your report: enter image description here

And if you have defined any functions as described above, they are displayed on the function tab.

+7
source

I have had success using this method:

  • Use a table in memory such as TkbmMemTable, TdxMemTable, or any table in memory.

  • Associate the table in memory with TfrDataSet.

  • Fill the table in memory using the usual TDataset methods and run the report.

+1
source

You might want to take a look at using NexusDB as a way to store data for a report. NexusDB is a database that, in addition to the full client server database, can also work as a full database in a database with full SQL support, as well as no external dlls or anything necessary, as it is compiled into your application. They have a free built-in version that will suit your needs. I use it for many things, to be honest, it’s a great tool in your toolbar.

0
source

All Articles