In the usual server/client mode mis development, there are always endless reports need to be made, the time to debug the report is also the most tedious, and often can not meet customer requirements. If you can let the user adjust the format and content of the report, and then save it, the next time the program starts, it automatically calls the saved report format that's how good. I finally realized the requirements through the following methods.
PB (PowerBuilder) has a special file format to save the report at the end of PSR (this is referred to as the PSR file). According to the principle that the data window can directly read the PSR file to generate the report, the program will save the dynamic report format by generating the PSR file.
First, the realization principle:
The report in PB is actually the equivalent of a data window.
The first step is to implement the dynamic report. By setting the resizeable and moveable properties of the Data Window objects (DataObject), such as the Chinese text, columns, and so on, to achieve the drag control of the object position, the Modify function of the data window is used to change the object value (including adding and deleting).
The second step is to save the report format. In an application, the name of the data window object is always unique, transforming each data window object into a PSR file in a database table. When the window is open, the program first verifies that the report format exists. If present, read the report format in a temporary file, then set the Data window (DataWindow) data Object (DataObject) as the report file, then extract the data, and if not, extract the data directly.
Second, the realization process:
1, set up a database table to save the report format file.
Table Name: Dyn_report |
Dwobject |
VARCHAR2 (20) |
Data Window object Name |
Primary Key |
Rptitle |
VARCHAR2 (80) |
Title Name of the report |
|
Memo |
Long |
Raw |
Report Format |
2, establish a window w_temp. Define instance variables as follows:
String Is_dwtype,is_dwobject//Save the type and name of the object in the report
Control Name |
Control meaning |
Dw_print |
Data Window objects |
Cb_exit |
Exit button |
Cb_savereport |
Report Format Save button |