A kind of report customization automatic generation method based on graphical mapping relations and device
Technical field
The invention belongs to report generation technical field, a kind of customization reports based on graphical mapping relations
Table automatic generation method.
Background technology
In automatization test system, auto report completing technology is more and more important, not only tester from loaded down with trivial details
Manually recorded test data procedures frees, and decreases error, the mistake that anthropic factor causes, thus significantly improve
Testing efficiency and the quality of test data.
Due to historical reasons, the test of a lot of products has defined the form of unique form.This have unique lattice
The form of formula is referred to as report customization.Automatization test system automatically generates for report customization, generally uses following two side
Formula: the first is to be realized at code layer by the peopleware of system integrator;The second uses general-utility test platform software to carry
Report generation software realize, report generation software can only run in platform software, and can not in other systems soft ware
Run.
It is to utilize the form instrument of third party's office software, bookmark function to set up report form template, according to template that coding realizes
Structure carrys out the structure of preparing datasource, sets up the data in data source and bookmark name one-to-one relationship, calls third party's office
Bookmark in report form template is replaced to the data specified by software interface, finally saves as target report file;Platform software is real
Mainly having American National instrument software LabView, it is that form quickly generates work that the report customization of this product generates dbase
Tool bag.Form quickly generates tool kit by obtaining the bookmark in template file, the most also must prepare according to formwork structure
The structure of data source, sets up the mapping relations of bookmark and data source, then by calling third party's office software interface data
Data in source are filled into the position that bookmark is corresponding, finally save as target report file.
The substantial amounts of time be will take for for both above method editor's bookmark.Set up and amendment bookmark can not be in report generation
Software is edited, and is intended to first add in third party's office software the bookmark of correspondence, make troubles to user operation;Data
And mapping simply by the title one_to_one corresponding between them of bookmark, for the amendment of a wherein side, the opposing party also to do accordingly
Amendment;And filling process when testing data entrance form is also transparent for user, user cannot revise, such as root
Whether dynamically changing the color of test data in test threshold values according to test data, these functions are the most equal
Cannot realize.
Therefore, prior art existing defects, need to improve.
Summary of the invention
The technical problem to be solved is for the deficiencies in the prior art, it is provided that a kind of based on graphically mapping pass
The report customization automatic generation method of system.
Technical scheme is as follows:
A kind of report customization automatic generation method based on graphical mapping relations, wherein, comprises the following steps:
Step 1: carry out template drafting;
Step 2: set up the mapping relations of visual edit test data and report form template;
Step 3: report generation;
Step 4: check whether described form meets customized demand, as met customized demand, then exports and/or prints;As
It is unsatisfactory for customized demand and then determines whether that template needs amendment, return step 1 in this way, as otherwise determined whether mapping relations
Need amendment, the most then return step 2, as otherwise terminated.
Described report customization automatic generation method, wherein, described step 1 specifically performs following steps:
Step 101: newly-built or open an empty template file;
Step 102: draw template file;
Step 103: whether template file meets customized demand;The most then save as new template file, otherwise after name
Return step 102.
Described report customization automatic generation method, wherein, described in described step 102 draw template for add form,
Amendment table style, the title of interpolation row, column.
Described report customization automatic generation method, wherein, the mapping relations in described step 2 are for using row tableau format
The mode of organising map relation, each mapping relations corresponds to a list items, includes mapping relations in a list items
Predetermined information;Described predetermined information is test data, Filling power, filling type, the threshold values of test data and font color.
Described report customization automatic generation method, wherein, the mapping relations in described step 2 include filling information and reflect
Penetrate relational term set;Described filling information is made up of template file type, template file pathname, file destination pathname;Institute
State mapping relations item set, the set being made up of mapping relations item;Described mapping relations item includes: test related data is in table
Positional information, fill data, fill type, threshold information;Described test related data positional information in table is by table rope
Quotation marks, line index number, column index number composition;Described filling data are Word message or data message;Described numerical information is single
Point value, one-dimension array, the data type of two-dimensional array;Described filling type is the mode that data are filled in template file, point
For single cell, single file, single-row, multiple lines and multiple rows, do not enter form etc..Described threshold information is that the threshold values to test data is sentenced
Disconnected, according to judged result, the color of font when self-defined test data enter form.
Described report customization automatic generation method, wherein, described step 3 specifically performs following steps:
Step 301: loading data source, obtains data list;
Step 302: resolve template file path, obtain template file object;
Step 303: perform mapping relations item successively;
Step 304: obtained filling data, filling region, filling type by the data object in mapping relations, complete corresponding
Filling;
Step 305: judge that whether mapping relations are last in set, the most then generate file destination form;As
Otherwise return step 303.
Described report customization automatic generation method, wherein, described step 304 specifically performs following steps:
Step 3041: for single cell, filling data is single value, when thresholding arranges enable, filling data
Comparing with thresholding, when being in thresholding, arranging filling font color is default color, otherwise for the color that transfinites;Face will be specified
The filling data of color write region to be filled;When thresholding does not enables, directly write region to be filled filling data;
Step 3042: filling corresponding filling data for single file is one-dimension array, first the Section 1 filling data
Write region to be filled;The next item down filling data is filled into the right cell of previous step;Perform successively laterally to fill laterally
Size cell;
Step 3043: the filling data corresponding for single-row filling are one-dimension array, the Section 1 write filling data
Region to be filled;The next item down filling data is filled into the lower unit lattice of previous step;Perform successively longitudinally to fill longitudinal size
Individual cell;
Step 3044: fill for multiple lines and multiple rows, corresponding data are two-dimensional array, fill widthwise size by single file single
Unit's lattice, circulation single file is filled successively, fills longitudinal size row until terminating.
A kind of report customization automatically generating device based on graphical mapping relations, wherein, draws aobvious including report form template
Show module, graphical mapping relations editing machine and report generation module is connected with each other and mutually communication;Described report form template is drawn
Display module, is used for providing template to draw and report display, and provides general-purpose interface to draw, shows and printing reports;Described
Graphical mapping relations editing machine, for providing visual edit test data and the mapping relations of report form template, test data
Enter filling mode during form;Described report generation module, for realizing the data source filling to form, is drawn by form
The interface of module realizes output and the printing of form.
The present invention uses and draws, by report form template, the scheme that display module is drawn, it is not necessary to prepare and formwork structure
The data source joined, thus saved the plenty of time;Graphical mapping relations editing machine provides visual for general data source and template
The mode changed sets up mapping relations, brings the more intuitive effect of user and higher operability, it is also possible to visualization amendment data
Enter filling mode during form.Test operation personnel can reduce operator's by revising graphical mapping relations
Requirement, has saved development cost;Being run by the visualization of report generation module, real-time enters template style and mapping relations
Row checks, modifies them in time, improves development efficiency;By providing the judgement of threshold values, it is also possible to test data just
Really property is verified.
Accompanying drawing explanation
Fig. 1 is the flow chart of report customization automatic generation method of the present invention;
Fig. 2 is that in report customization automatic generation method of the present invention, template draws flow chart;
Fig. 3 is report generation flow chart in report customization automatic generation method of the present invention.
Detailed description of the invention
Below in conjunction with the drawings and specific embodiments, the present invention is described in detail.
Embodiment 1
As Figure 1-3, report customization Autos based on graphical mapping relations, it is divided into report form template to draw
Display module, graphical mapping relations editing machine, report generation module three part.Report form template is drawn display module and is provided template
Draw function and report display function, and provide general-purpose interface to draw and show, printing reports;Graphical mapping relations editor
Device is test operation personnel, it is provided that visual edit test data enter form with mapping relations, the test data of report form template
Time filling mode;Report generation performs module, it is achieved the filling of data source to form, real by the interface of form drafting module
The output of existing form and printing.
The cooperation relation of three parts: first run report form template drafting display module and carry out editing template, then run figure
Change data and the corresponding relation of template position in mapping relations editing machine editor's data source, finally run report generation module and produce
Form, compares generation form the most consistent with customized demand, revises template or amendment mapping relations, then run time inconsistent
Report generation module, compares generation target form the most consistent with customized demand again;Terminate time consistent.
It is manually to set up report form template that report form template draws display module, and idiographic flow is as shown in Figure 2.The most newly-built one
Empty template file step 101, utilizes drawing tool, draws template, adds form, amendment table style, the name of interpolation row, column
Claiming step 102, with requirements comparison step 103, during until fully meeting demand, saving as new template.
Graphical mapping relations editing machine is initially with being set up the data in data source and form by patterned mode
The mapping relations of template.Can use format organization's mapping relations of list, each mapping relations corresponds to a list items,
One list items includes all information needed for mapping relations, including test related data, Filling power, the valve of test data
Value, color etc..The basic operation of graphical mapping relations editing machine is divided into interpolation, deletes, empties, upper shifting, moves down, and uses this
A little easy to operate quickly set up mapping relations.
Mapping relations, are gathered two parts by filling information and mapping relations item: wherein filling information by template file type,
Template file pathname, file destination pathname etc., the design of filling information structure is as shown in table 1 below:
Mapping relations item set, the set being made up of mapping relations item, wherein mapping relations item includes: test dependency number
According to the positional information in table, fill data, filling type, threshold information etc..Test related data positional information in table
It is made up of table index number, line index number, column index number.Filling data can be Word message, it is also possible to be numerical information etc., number
Value information provides the support of the data type of One-Point-Value, one-dimension array, two-dimensional array.Filling type is that data are filled into template
Mode in file, is divided into single cell, single file, single-row, multiple lines and multiple rows, does not enter form etc..Mapping relations item structure designs
As shown in table 2 below:
Threshold information provides the threshold values of test data and judges, according to judged result, self-defined test data can enter report
The color of font during table.Structure design is as shown in table 3 below:
Report generation performs visualization operational mode and operation, stopping, the pausing operation providing form to fill.Report generation
Performing flow process is that the first step obtains data source object step 301 in a test system;Second step opens template file, obtains template
Table objects step 302 in file;3rd step performs mapping relations successively, by the table number in mapping relations, line number, row structure
Become positional information, table objects obtains region to be filled step 303;Filler is obtained by the data object in mapping relations
According to;It is filled with in different ways by the filling in mapping relations: 1) for single cell, filling data is single value,
When thresholding arranges enable, compare with thresholding filling data, when in thresholding, filling font color is set for acquiescence face
Color, otherwise for the color that transfinites, writes region to be filled the filling data of designated color;When thresholding does not enables, directly filling out
Make up the number according to writing region to be filled;2) filling corresponding filling data for single file is one-dimension array, first filling data
Section 1 writes region to be filled;The next item down filling data is filled into the right cell of previous step;Perform successively laterally to fill out
Fill X to size cell.3) the filling data for single-row filling correspondence are one-dimension array.The Section 1 filling data is write
Enter region to be filled;The next item down filling data is filled into the lower unit lattice of previous step;Perform successively longitudinally to fill Y-direction size
Individual cell.4) filling for multiple lines and multiple rows, corresponding data are two-dimensional array.By single file filling X to size cell, depend on
Secondary circulation single file is filled, and fills Y-direction size row and terminates.4th step circulates the 3rd step successively, filling data all in list all
In write form;5th step table objects saves as file destination, or directly opens or printout.
Embodiment 2
On the basis of above-described embodiment, as shown in Figure 1: provide a kind of report customization based on graphical mapping relations certainly
Dynamic generation method, wherein, comprises the following steps:
Step 1: carry out template drafting;
Step 2: set up the mapping relations of visual edit test data and report form template;
Step 3: report generation;
Step 4: check whether described form meets customized demand, is to export and/or print;Otherwise enter step 5;
Step 5: continue to determine whether to need amendment for template, is then to return step 1, otherwise enters step 6;
Step 6: continue to determine whether to need amendment for mapping relations, as then returned step 2, otherwise terminate.
Described report customization automatic generation method, wherein as in figure 2 it is shown, described step 1 specifically performs following steps:
Step 101: newly-built or open an empty template file;
Step 102: draw template file;
Step 103: whether template file meets customized demand;The most then save as new template file, otherwise after name
Return step 102.
Described report customization automatic generation method, wherein, described in described step 102 draw template for add form,
Amendment table style, the title of interpolation row, column.
Described report customization automatic generation method, wherein, the mapping relations in described step 2 are for using row tableau format
The mode of organising map relation, each mapping relations corresponds to a list items, includes mapping relations in a list items
Predetermined information;Described predetermined information is test data, Filling power, filling type, the threshold values of test data and font color.
Described report customization automatic generation method, wherein, the mapping relations in described step 2 include filling information and reflect
Penetrate relational term set;Described filling information is made up of template file type, template file pathname, file destination pathname;Institute
State mapping relations item set, the set being made up of mapping relations item;Described mapping relations item includes: test related data is in table
Positional information, fill data, fill type, threshold information;Described test related data positional information in table is by table rope
Quotation marks, line index number, column index number composition;Described filling data are Word message or data message;Described numerical information is single
Point value, one-dimension array, the data type of two-dimensional array;Described filling type is the mode that data are filled in template file, point
For single cell, single file, single-row, multiple lines and multiple rows, do not enter form etc..Described threshold information is that the threshold values to test data is sentenced
Disconnected, according to judged result, the color of font when self-defined test data enter form.
Described report customization automatic generation method, wherein as it is shown on figure 3, described step 3 specifically performs following steps:
Step 301: loading data source, obtains data list;
Step 302: resolve template file path, obtain template file object;
Step 303: perform mapping relations item successively;
Step 304: obtained filling data, filling region, filling type by the data object in mapping relations, complete corresponding
Filling;
Step 305: judge that whether mapping relations are last in set, the most then generate file destination form;As
Otherwise return step 303.
Described report customization automatic generation method, wherein, described step 304 specifically performs following steps:
Step 3041: for single cell, filling data is single value, when thresholding arranges enable, filling data
Comparing with thresholding, when being in thresholding, arranging filling font color is default color, otherwise for the color that transfinites;Face will be specified
The filling data of color write region to be filled;When thresholding does not enables, directly write region to be filled filling data;
Step 3042: filling corresponding filling data for single file is one-dimension array, first the Section 1 filling data
Write region to be filled;The next item down filling data is filled into the right cell of previous step;Perform successively laterally to fill laterally
Size cell;
Step 3043: the filling data corresponding for single-row filling are one-dimension array, the Section 1 write filling data
Region to be filled;The next item down filling data is filled into the lower unit lattice of previous step;Perform successively longitudinally to fill longitudinal size
Individual cell;
Step 3044: fill for multiple lines and multiple rows, corresponding data are two-dimensional array, fill widthwise size by single file single
Unit's lattice, circulation single file is filled successively, fills longitudinal size row until terminating.
Embodiment 3
On the basis of above-described embodiment, it is provided that a kind of report customizations based on graphical mapping relations automatically generate dress
Put, wherein, including report form template draw display module, graphical mapping relations editing machine and report generation module is connected with each other and
Mutually communication;Described report form template draws display module, is used for providing template to draw and report display, and provides general-purpose interface
Draw, show and printing reports;Described graphical mapping relations editing machine, is used for providing visual edit test data and form
The filling mode when mapping relations of template, test data entrance form;Described report generation module, is used for realizing data source and arrives
The filling of form, realizes output and the printing of form by the interface of form drafting module.
Modules in said apparatus is connected with each other and mutually uses in communication implementation and method and embodiment 2
Method and step are identical, and the flow process that concrete grammar realizes, as shown in content in Fig. 1-Fig. 3 and embodiment 2, does not repeats them here.
It should be appreciated that for those of ordinary skills, can be improved according to the above description or be converted,
And all these modifications and variations all should belong to the protection domain of claims of the present invention.