Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a report using fast Reports with out connecting directly to a database

I have been asked by my company to update the reporting functionality of a paticular application written in delphi and using Quick reports to use FastReports instead.

The current implementation pulls all the data out of the database, does a lot of work to organise and calculate the required data for the reports and stores all this in several different objects. The Quick Report OnNeedData events are then used to fill out the bands until there is no more data (signified by setting MoreData = false)

The problem I'm having is Fast Reports seems to need a band to be connected to an actual data source, which I don't have. Also fastReports doesn't seem to have an event similar to OnNeedData.

Is there anyway to fill out the values of a data band in code and have it print again until all data is printed without connecting the band to a dataset?

I appologise for the vagueness of this question, I am very new to reporting software and any suggestions of where to go and what to look at would be greatly appreciated.

like image 374
Crunchie Avatar asked Dec 17 '12 04:12

Crunchie


People also ask

What is fast report?

FastReport® VCL - is an add-on component that allows your application to generate reports quickly and efficiently. FastReport® provides all the necessary tools to develop reports, including a visual report designer, a reporting core, and a preview window.

Is fast report free?

FastReport provides free open source report generator for . NET 6/. NET Core/. NET Framework.


4 Answers

Fast reports use a intermediary object descending from _TFrxDataSet to connect the report engine which the data it prints.

To connect a report to a data source managed by the program itself, you use a TfrxUserDataSet component, which let's you see a data set inside the report, but you manually specify the column names in the Fields (TStrings) property and manage and supply values programatically writing event handlers for the following events:

  • OnCheckEOF is functionally equivalent to the OnNeedData, if there's no more to print, you set the EOF var parameter to true
  • OnFirst you do whatever you have to do to start walking for the data.
  • OnGetValue and OnNewGetValue you provide values for each of the different columns of the current row
  • OnNext, OnPrior you move your current row one next or one prior position.

As you see, the row/column concept (a DataSet) is used to provide the data to the report, but you can pull your data from any structure you use to store the result of your calculations (lists, arrays, or any other object/structure/file etc.)

Inside the report, you link the band to this logical DataSet and you use standard components to print the column values of this DataSet.

If you already have the data in a DataSet, for example a in-memory DataSet after your calculations, better use a TfrxDBDataset to directly bind your report to that source of data.

like image 113
jachguate Avatar answered Oct 20 '22 14:10

jachguate


you can use TfrxUserDataSet.There is a demo named 'printstringlist' under folder 'demos'.

like image 27
kazarus Avatar answered Oct 20 '22 15:10

kazarus


In our project we have implemented our own class inherited from TfrxCustomQuery. This new query class simply redirects its SQL statements to our application' internal query engine. We registered this new class in FastReport palette (used frxDsgnIntf.frxObjects.RegisterObject* for FR version 3 and 4) and now it is used in all our report templates instead of TfrxADOQuery or other built-in dataset classes.

like image 2
Anton R. Avatar answered Oct 20 '22 16:10

Anton R.


Here is another alternative:

I've been using FastReport for years. I sometimes run into a similar situation. For offline tabular reports I use an in-memory dataset. I purchased DevExpress long time ago and so I have TdxMemData. But even without it, you should be happy using the TClientDataset component.

Besides that, the TfrxUserDataset is an alternative which I use when showing lists of objects.

like image 1
alzaimar Avatar answered Oct 20 '22 15:10

alzaimar