hk_reportsection represents a section in a hk_report element. Within a section you can define the outputdata,use it as headers for your data and so in If it is needed as a section header or footer use set_unique() in combination with set_uniquecolumn() It also can contain subreports.
Usually section come as "twins", a header section and a footer section belonging to each other, see hk_reportsectionpair for details
Example 2.12. Creating a CSV export file based on a report
Example: Defining a CVS output (no first row with columnnames)
p_driver=hk_drivermanager() connect=p_driver.new_connection("mysql") connect.set_user("root") connect.set_host("localhost") connect.set_password("my_password") connect.connect() database=connect.new_database("exampledb") e=hk_report() e.set_reporttype("Userdefined") datasrc =e.new_datasource("authors",True)#loads an existing query e.set_presentationdatasource(datasrc) section=e.datasection() section.set_default_data("\"%VALUE%\"")# define " before and after the value of a column section.set_betweendata(" , ")# a comma separated list section.set_sectionend("\n")# one row per datarow e.execute()
You can use the variables
%PAGENUMBER% the number of the page
%ABSOLUTEPAGENUMBER% physical number of the page in file
Inherits from hk_dsdatavisible.
- set_unique([is_unique[,endsection]])
If the section should be printed just once per block and not for each datarow use this function. If 'unique' true if this section should be printed once. If 'endsection' true if this section should not be printed as a header. Instead it will be printed at the end of the block. Sections created with hk_reportsectionpair are already set correctly.
- unique()
returns True if this is a unique section.
- new_data()
returns a new object of type hk_reportdata.
- data_at(position)
returns an existing object of type hk_reportdata.
- actual_string()
Internal function. Returns the string that will be printed.
- set_sectionbegin(sbegin)
The sectionbegin will be printed as a header of the section (before the data).
- sectionbegin()
returns the section begin string.
- set_sectionend()
The sectionend will be printed as a footer of the section (after the data)
- sectionend()
returns the section end string.
- set_betweendata()
A string that will be printed between two datasegments defined with new_data(). E.g. If you want a comma separated list you would need set_betweendata(" , ").
- betweendata()
returns the value that will be printed between 2 data fields
- new_uniquevalue(justcheck)
returns True if this section is a unique section and this section has to be printed. If 'justcheck' is True no variables(lastvalue) will be changed
- endsection()
Returns True if this section is a unique section and will be printed behind the data.
- set_automatic_create_data(automatic)
If set true and you haven't defined any data with new_data() it will automatically create the data objects.
- set_new_page_after_section(npage)
If 'npage' is True a new page will be started after printing this section. Usually this function should only be used in combination with set_unique() as an endsection.
- new_page_after_section()
returns true if a new page at the end of the section will be started.
- set_subreport(reportname [,before_data])
A complete report can be printed within a section. If 'before_data' is true the subreport will be printed before the data of this section will be printed, else it will be printed after the data.
- subreportname()
returns the name of the subreport
- subreport()
returns the subreport as a object of type hk_report.
- add_depending_fields(thisreport_field,subreport_field)
If you set a subreport with set_subreport() add the fields which are connected between the reports
- clear_depending_fields()
Clears the field definition for subreports.
- depending_on_thisreportfields()
Returns a list of the connected fields of this report, which are connected to the subreport.
- depending_on_subreportfields()
Returns a list of the connected fields of the subreport, which are connected to this report.
- print_subreport_before_data()
returns True if the subreport will be printed before the data.
- reset_count()
Will set all COUNT, SUM, AVERAGE and so on variables to 0, if they are not "running counts" (which mean global for the whole report).See hk_reportdata for details. Usually you dont't have to call this function
- counts_as()
- set_default_reportdata(value)
The 'value' will be used as a default when a new data will be created with new_data() The preset value is @VALUE@.
- default_reportdata()
- set_default_beforereportdata(value)
The 'value' will be used as a default when a new data will be created with new_data()
- default_beforereportdata()
- set_default_afterreportdata()
The 'value' will be used as a default when a new data will be created with new_data()
- default_afterreportdata()
- report()
Returns the hk_report object this section belongs to.
- reportsectionpair()
Returns the hk_reportsectionpair object this section belongs to.
- set_offset(value)
The offset is additional space at the end of the section (totalsectionsize= size needed by reportdata + offset)
- offset()
Returns the offset.
- get_reportdatavisible(number)
Returns a hk_reportdata object identified by a unique identifier number. Searches only within this section.
- get_reportdatavisible(identifier)
Returns a hk_reportdata object identified by a unique text identifier. Searches only within this section.