CN112446199A - Report generation method based on visual template - Google Patents

Report generation method based on visual template Download PDF

Info

Publication number
CN112446199A
CN112446199A CN201910746886.7A CN201910746886A CN112446199A CN 112446199 A CN112446199 A CN 112446199A CN 201910746886 A CN201910746886 A CN 201910746886A CN 112446199 A CN112446199 A CN 112446199A
Authority
CN
China
Prior art keywords
instruction
report
data
template
replacement
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910746886.7A
Other languages
Chinese (zh)
Inventor
杜建
陆一鸣
吕广宪
刘鹏
王立岩
段祥骏
李运硕
冯德志
张�杰
蒋宏图
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
State Grid Corp of China SGCC
China Electric Power Research Institute Co Ltd CEPRI
Original Assignee
State Grid Corp of China SGCC
China Electric Power Research Institute Co Ltd CEPRI
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by State Grid Corp of China SGCC, China Electric Power Research Institute Co Ltd CEPRI filed Critical State Grid Corp of China SGCC
Priority to CN201910746886.7A priority Critical patent/CN112446199A/en
Publication of CN112446199A publication Critical patent/CN112446199A/en
Pending legal-status Critical Current

Links

Images

Abstract

The report generation method based on the visual template can support the logical execution and result replacement of instructions, variables, conditional statements and functions based on the word design template, generate the required report by reconstructing and replacing the words and finally display the report result in the form of the words, can visually design the report template, can flexibly construct the actually required displayed report result by means of the instructions, the variables, the conditional statements and the functions, and is convenient, flexible and easy to use.

Description

Report generation method based on visual template
Technical Field
The invention relates to the field of computers, in particular to a report generation method based on a visual template.
Background
The current commonly used report forms have strong design specialties, and have the defects of insufficient expansibility and weak universality aiming at specific application environments. Office software is the most commonly used Office software at present, wherein a word template is provided with a report engine. The essence of the report engine of the word template is to realize the calculation of the variable expression and the replacement of the variable expression with the word typesetting format, thereby generating the report required by the user.
However, when the visual editing template is implemented by making the template with the word, the text content in the paragraph is randomly distributed, so that the situation that the computational expression cannot be correctly extracted or the non-expression part is wrongly replaced occurs, and the correct generation of the visual editing template is finally influenced, and the support of the common report tool for the word is insufficient.
Disclosure of Invention
The invention provides a report generation method based on a visual template, which can be applied to the verification result data of a model verification tool and can generate a report according to the verification result data.
The invention provides a report generation method based on a visual template, which is characterized by comprising the following steps:
step S1: according to the actual report requirement, writing a corresponding instruction in the word document, and constructing a report template;
step S2: reading an instruction defined by the template document, and constructing an instruction set;
step S3: constructing report processing tools of paragraphs, pictures and tables, and respectively preprocessing the paragraphs, the pictures and the tables in the documents;
step S4: executing the instruction based on the constructed instruction set;
step S5: and outputting a report result.
Preferably, the step S1 includes:
model checking result data are generated by checking the model file through the model checking tool, the model checking result data are formatted based on the WordTable data structure, and the model checking result data are used for filling the report.
Preferably, the step S2 further includes:
it is determined whether the instruction is a loop instruction or a normal instruction.
Preferably, the step S2 further includes:
the loop instruction is used for realizing the replacement of a plurality of pieces of data, and the common instruction is used for realizing the replacement of a single piece of data.
Preferably, the replacing comprises:
the data replacement is directly performed.
Preferably, the replacing comprises:
and carrying out data replacement on the basis of the conditional judging statement and the function.
Preferably, the step S3 includes:
the method comprises the steps of operating a word document based on an Apache POI tool, carrying out structure reconstruction on dispersed paragraph contents in the word document, and merging the paragraph contents into the same XWPFRun.
The report generation tool based on the visual template can support the logic execution and result replacement of instructions, variables, conditional statements and functions based on the word design template, generate a required report by reconstructing the word and replacing data, and finally display the report result in a word form. The design of the report template can be visually carried out, and meanwhile, the report result which is actually required to be displayed can be flexibly constructed by means of instructions, variables, conditional statements and functions, and the use method is convenient, flexible and easy to use.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
FIG. 1 is a logical flow chart of report generation in an embodiment of the present invention;
FIG. 2 is a flowchart illustrating replacement execution of word report document data according to an embodiment of the present invention.
Detailed Description
The present invention will be described in detail with reference to specific examples. The following examples will assist those skilled in the art in further understanding the invention, but are not intended to limit the invention in any way. It should be noted that it would be obvious to those skilled in the art that various changes and modifications can be made without departing from the spirit of the invention. All falling within the scope of the present invention.
The report generation method provided by the invention can be applied to the verification result data of the model verification tool and can generate a report according to the verification result data.
Referring to fig. 1, in the present embodiment. Processing the self-defined word template document based on the Apache POI and the JEXLENE engine, and generating a required report file through data replacement and document structure reconstruction. The specific implementation steps are as follows:
s1: and writing a proper instruction in the word document according to the actual report requirement, and constructing a report template. Model checking result data are generated by checking the model file through the model checking tool, the model checking result data are formatted based on the WordTable data structure, and the model checking result data are used for filling the report.
S2: based on the formulated report template, reading an instruction defined by a template document, judging whether the instruction is a loop instruction or a common instruction, and constructing an instruction set. The loop instruction is used for realizing the replacement of a plurality of pieces of data, the common instruction is used for realizing the replacement of single data, and in the single data replacement, the data replacement can be directly carried out, and the data replacement can also be carried out based on the conditional judgment statement and the function.
S3: and respectively preprocessing paragraphs, pictures and tables in the document. The document is composed of a table and paragraphs, the paragraphs are composed of texts and pictures, and the specific contents of cells in the table are composed of the paragraphs. The method is characterized in that a word document is operated based on an Apache POI tool, the structure of the paragraph contents scattered in the word document is reconstructed and is merged into the same XWPFRun, the data replacement is convenient to carry out subsequently, and the specific processing method refers to a patent report generation method and a system. The table is made up of a set of lines, the lines are made up of a set of cells, the cells are made up of a set of paragraphs, and the logic for processing paragraphs is as described above.
S4: and executing the instruction based on the constructed instruction set, and realizing variable replacement and execution of conditional statements and functions based on the JexlEngine and the JexlContext. And operations such as image replacement, cell merging, paging and the like are completed based on the Apache POI tool in combination with the instruction. The specific execution flow is shown in FIG. 1, and the logic execution steps are shown in S41-S43.
S41: the processed objects are divided into paragraphs, pictures and tables, the paragraphs are processed, data filling is performed according to the word template, specific execution logic is shown in steps S411-S414, and the execution flow is shown in fig. 2.
S411: and performing paragraph processing, reading paragraph contents, and extracting a variable expression based on the regular expression if the paragraph contents are common instructions, wherein the variable expression comprises directly replaced variables, conditional statements, arrays and functions. If the instruction is a loop instruction, the loop instruction is firstly analyzed through the regular expression, and then the analyzed variable is processed through the loop according to the logic of the common instruction.
S412: and acquiring the analyzed variable expression set, and if the variable expression is not a conditional statement, realizing mapping conversion of the variable expression and corresponding data based on JexlContext and relating to a function, and executing the acquired data result based on the function. The report tool supports various functions, wherein aV (notes, col) is used for calculating the maximum value of a first col column of data corresponding to notes variables; aH (notes, row) is used for calculating the maximum value of the row of the data corresponding to the notes variable; the iV (lists, col) is used for calculating the minimum value of the first col column of the data corresponding to the lists variable; iH (lists, row) is used for calculating the minimum value of the row of data corresponding to the lists variable; the sV (lists, col) is used for calculating the sum of the first col columns of the data corresponding to the lists variables; sH (lists, row) is used for calculating the sum of the row of the data corresponding to the lists variable; ev (notes, col, param) acquires the number of the col columns of data corresponding to notes variables equal to param; eh (notes, col, param) acquires the number of rows of data corresponding to notes variables equal to the number of params; df (fmt, time) is used for time formatting, fmt is a formatted string, time is seconds, and fmt format is yyyy-MM-dd HH: MM: ss.
S413: if the variable expression is a conditional statement, the conditional statement needs to be segmented to obtain an expression which is a variable, an array or a function, and then the processing is performed according to step S412.
S414: after data corresponding to the variable expression set is obtained, conducting document structure reconstruction and data replacement based on Apache POI operation XWPFRun. If the instruction is a loop instruction, judging whether the instruction is the last loop, if not, adding XWPFRun to the XWPFRun set, and if the instruction is the last loop, replacing the content in the XWPFRun set; if the command is a conditional command in the common command, judging whether the condition is met, if so, replacing the content in the matched XWPFRun, otherwise, emptying the matched XWPFRun; and if the instruction is an unconditional instruction in the common instruction, replacing the content in the matched XWPFRun, and if the content is not matched, using/replacing.
S42: and performing picture replacement processing, extracting a variable expression through a regular expression, acquiring parameters set by the picture, finishing mapping conversion of picture data and an instruction expression based on JexlContext, and setting the picture into a word document through an Apache POI tool and the picture data.
S43: performing table processing, mainly processing the paragraph contents in the cells, using a { p } expression to perform page-changing operation, using a { m } expression to perform cell merging operation at a corresponding position, judging whether the last cycle is involved if the cycle instruction is involved, adding XWPFTableCell to XWPFTableCell set if the last cycle is not involved, and replacing the contents in the XWPFTableCell set if the last cycle is involved, wherein the paragraph set processing method in the XWPFTableCell is consistent with the paragraph processing method. If the text content of the paragraph in the XWPFTableCell is a conditional instruction in the common instruction, judging whether the condition is met, if so, replacing the content in the matched XWPFRun, otherwise, emptying the content in the matched XWPFRun; and if the text content of the paragraph in the XWPFTableCell is an unconditional instruction in the common instruction, replacing the content in the matched XWPFRun, and if the content is not matched, replacing the content.
S5: and finishing the generation of the report and outputting the report in a word form.
According to the report generation method and system, the word document is analyzed based on the Apache POI, and operations such as the style, the color setting, the cell merging, the page changing and the like of the word can be performed; and processing the self-defined report instruction based on the JexlEngine to realize variable replacement, control instruction execution, expression execution and self-defined function execution. And the report forms are flexibly generated under the cooperation of the two modules.
It should be noted that, the steps in the report generation method provided by the present invention can be implemented by using corresponding modules, devices, units, and the like in the report generation system, and those skilled in the art can implement the step flow of the method by referring to the technical scheme of the system, that is, the embodiment in the system can be understood as a preferred example for implementing the method, and details are not repeated here.
Those skilled in the art will appreciate that, in addition to implementing the system and its various devices provided by the present invention in purely computer readable program code means, the method steps can be fully programmed to implement the same functions by implementing the system and its various devices in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Therefore, the system and various devices thereof provided by the present invention can be regarded as a hardware component, and the devices included in the system and various devices thereof for realizing various functions can also be regarded as structures in the hardware component; means for performing the functions may also be regarded as structures within both software modules and hardware components for performing the methods.
The foregoing description of specific embodiments of the present invention has been presented. It is to be understood that the present invention is not limited to the specific embodiments described above, and that various changes or modifications may be made by one skilled in the art within the scope of the appended claims without departing from the spirit of the invention. The embodiments and features of the embodiments of the present application may be combined with each other arbitrarily without conflict.

Claims (7)

1. A report generation method based on a visual template is characterized by comprising the following steps:
step S1: according to the actual report requirement, writing a corresponding instruction in the word document, and constructing a report template;
step S2: reading an instruction defined by the template document, and constructing an instruction set;
step S3: constructing report processing tools of paragraphs, pictures and tables, and respectively preprocessing the paragraphs, the pictures and the tables in the documents;
step S4: executing the instruction based on the constructed instruction set;
step S5: and outputting a report result.
2. The method for generating reports based on visual templates of claim 1, wherein the step S1 comprises:
model checking result data are generated by checking the model file through the model checking tool, the model checking result data are formatted based on the WordTable data structure, and the model checking result data are used for filling the report.
3. The method for generating reports based on visual templates of claim 2, wherein the step S2 further comprises:
it is determined whether the instruction is a loop instruction or a normal instruction.
4. The method for generating reports based on visual templates of claim 3, wherein the step S2 further comprises:
the loop instruction is used for realizing the replacement of a plurality of pieces of data, and the common instruction is used for realizing the replacement of a single piece of data.
5. The visualization template-based report generation method according to claim 4, wherein said replacing comprises:
the data replacement is directly performed.
6. The visualization template-based report generation method according to claim 4, wherein said replacing comprises:
and carrying out data replacement on the basis of the conditional judging statement and the function.
7. The method for generating reports based on visual templates of claim 1, wherein the step S3 comprises:
the method comprises the steps of operating a word document based on an Apache POI tool, carrying out structure reconstruction on dispersed paragraph contents in the word document, and merging the paragraph contents into the same XWPFRun.
CN201910746886.7A 2019-08-14 2019-08-14 Report generation method based on visual template Pending CN112446199A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910746886.7A CN112446199A (en) 2019-08-14 2019-08-14 Report generation method based on visual template

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910746886.7A CN112446199A (en) 2019-08-14 2019-08-14 Report generation method based on visual template

Publications (1)

Publication Number Publication Date
CN112446199A true CN112446199A (en) 2021-03-05

Family

ID=74741887

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910746886.7A Pending CN112446199A (en) 2019-08-14 2019-08-14 Report generation method based on visual template

Country Status (1)

Country Link
CN (1) CN112446199A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113467881A (en) * 2021-09-01 2021-10-01 南方电网数字电网研究院有限公司 Method and device for automatically adjusting chart style, computer equipment and storage medium
WO2023115833A1 (en) * 2021-12-24 2023-06-29 永中软件股份有限公司 Streaming document generation method, computing device, and computer readable medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113467881A (en) * 2021-09-01 2021-10-01 南方电网数字电网研究院有限公司 Method and device for automatically adjusting chart style, computer equipment and storage medium
CN113467881B (en) * 2021-09-01 2021-11-16 南方电网数字电网研究院有限公司 Method and device for automatically adjusting chart style, computer equipment and storage medium
WO2023115833A1 (en) * 2021-12-24 2023-06-29 永中软件股份有限公司 Streaming document generation method, computing device, and computer readable medium

Similar Documents

Publication Publication Date Title
CN102929473B (en) Document data entry suggestions
CN106598869A (en) Method and device for realizing automatic software testing and electronic equipment
CN109284103A (en) A kind of Web application and development and update method based on control development mode
Karasneh et al. Extracting UML models from images
KR101950126B1 (en) Mathematical formula processing method, device, apparatus and computer storage medium
CN112446199A (en) Report generation method based on visual template
CN112446189A (en) Data processing method
CN105487956A (en) Debugging method and device in power-on self-test
US10061752B2 (en) Method and apparatus for generating a font of which style is changeable
JP2007011605A (en) Model inspection support device for software operation specification, model inspection system provided with the same, and model inspection support program
CN109086040A (en) A kind of method and system quickly generating html code
JP4803447B2 (en) CAD system and program implemented in this system
JP5109646B2 (en) Program source conversion device
Denwood et al. Package ‘runjags’
Bowen Egon Börger and Alexander Raschke: modeling companion for software practitioners
JP5702265B2 (en) Program automatic generation apparatus and program automatic generation method
CN113011148A (en) Method, device, equipment and medium for automatically outputting file with specified format
US20050262040A1 (en) Software Systems and Methods for Programmatically creating Graphical and Text Elements using OLE and/or Macro Functionality of Commercially Available Software Applications in the Background
CN114386374A (en) Method for generating odf document by using CA signature in data integration and program thereof
JP2020204855A (en) Keyword detection device and keyword detection method
CN110705249B (en) NLP library combined use method based on overlapping degree calculation
Sudarsan et al. Industrial Control Systems-Legacy System Documentation and Augmentation
US11829336B1 (en) Systems and methods for automated data dictionary generation and validation
JP6827610B1 (en) Development support equipment, programs and development support methods
JP7477027B1 (en) Information processing device, information processing method, and program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination