hk_report
Prev | Chapter 2. Classes in alphabetical order | Next

## hk_report

hk_report represents a report. It is a general report generator, that means it is able to not only print Postscript, hk_report is able to create any kind of text output. See set_reporttype().

A report is split in sections of type hk_reportsection. These sections contain the displayed data of type hk_reportdata. There are predefined sections:

- the datasection, which is the only section, that has not a sibling.

- the pageheader section and the pagefooter section,

- the reportheader section and the reportfooter section.

Self defined sections are grouped in pairs (a header and a footer section), which will be managed by a container object of type hk_reportsectionpair. To create a new sectionpair use new_sectionpair() and new_sectionpair_at().

Inherits from hk_presentation.

get_reportdatavisible(number)

  returns a hk_reportdata object identified by a unique identifier number

get_reportdatavisible(name)

  returns a hk_reportdata object identified by a unique text identifier

load_report([name])

  loads the report definition from a file, where 'name' is the name of the report

save_report([name [,ask]])

  Saves the report to a file, where 'name' is the name of the file. if 'ask' is true and the report already exists you will be asked before the old report will be overwritten. Returns True if successful else False.

datasection()

  returns the hk_reportsection object which represents the data section.

new_sectionpair()

  returns a new hk_reportsectionpair object which embraces the other sections.

new_sectionpair_at(position)

  returns a new hk_reportsectionpair object at position 'position. The most outside position is 0.

move_sectionpair(originalposition,steps)

  moves an existing hk_reportsectionpair relative to the other existing hk_reportsectionpair objects. The 'actualposition' is the current position of the sectionpair to be moved Parameter 'steps':positive values move it closer to the datasection, negative values move it away.

page_header()

  returns the page header section of type hk_reportsection. The page header section will be printed once at the beginning of every page.

page_footer()

  returns the page footer section of type hk_reportsection. The page footer section will be printed at the end of every page.

report_header()

  returns the report header section of type hk_reportsection. The report header section is printed once at the beginning of the report.

report_footer()

  returns the report footer section of type hk_reportsection.The report footer section is printed once at the end of the report.

set_firstpagenumber(number)

  Set the starting pagenumber if the first page should not start with 1.

firstpagenumber()

  returns the first page number.

set_filename(name)

  Sets the filename of the report. It will be used for the output of the report. If you don't give the report a name the report and use_standard_storagepath() is false will be printed at the standard output. See also set_fileextension().

filename()

  returns the filename

set_fileextension(extension)

  The output filename will be completed with this extension, i.e. '.ps' for postscript files

fileextension()

  returns the file extension.

set_reporttype(name)

  sets the report type 'name'.

reporttype()

  returns the set report type

reporttypelist()

  returns a list of all available report types.

Here is how to start a report:

Example 2.10. displaying a report

    myreport=hk_this.datasource().database().new_reportvisible()
    myreport.load_report("complexreport")
    myreport.set_mode(myreport.viewmode)

A visible object in a report is of type hk_reportdata, which inherits from hk_dsdatavisible. The main methods are

- set_data(const hk_string& d)

- hk_string data(void)

The data property contains the value that is displayed. See the knodatutorial chapter "The report field" for details.

The following example shows how to print numbers in different colours. For this we use the "onprint" action

Example 2.11. reportdata onprint

    value=hk_this.column().asdouble()
    if value<0:
       hk_this.set_foregroundcolour(hk_red)
    else:
       if value==0:
           hk_this.set_foregroundcolour(hk_black)
       else:
          hk_this.set_foregroundcolour(hk_blue)

Prev | Up | Next
hk_presentation | Home | hk_reportdata