The reportx Framework:
- Tcllib is an excellent set of libraries used in various areas of applications like networking, data structures, documentation, mathematics.... etc. etc.
- The ::report and struct::matrix packages of tcllib can be used to generate tabular reports such as the one below:
In this post, I will present a small framework that simplifies the usage of these two packages in generating tabular reports. This framework is named reportx. The reportx framework itself contains only one method/proc named ::reportx::format.
The format method takes 3 arguments (onely one mandatory and 2 optional):
- Tabular Format Template:
- Defines the structure of the report starting outer most table to rows inside the table and the columns in each row.
- Is a nested/recursive structure. Hence, you can define a cell to create sub-tables.
- Can have Tcl variable names (e.g. $company_name) that will be substituted with values later.
- Can also mention the name of the style definition to be applied to the outer most table, rows and columns.
- Data Values: Optional list of name-value pairs that will be used to substitute the variables in the template.
- Style Definitions: Optional list of style definitions of the style names used in the template
The signature of this method is:
proc ::reportx::format {template {subst_data ""} {styles_def ""}}
::reportx::format method returns a string that contains the entire formatted report that can be sent to a printing framework.
No comments:
Post a Comment