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

18,816

Solution 1

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.

Solution 2

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

Solution 3

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.

Solution 4

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.

Share:
18,816
Crunchie
Author by

Crunchie

Updated on June 13, 2022

Comments

  • Crunchie
    Crunchie almost 2 years

    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.