CN117131851A - Method for automatically generating text version report - Google Patents

Method for automatically generating text version report Download PDF

Info

Publication number
CN117131851A
CN117131851A CN202311091467.7A CN202311091467A CN117131851A CN 117131851 A CN117131851 A CN 117131851A CN 202311091467 A CN202311091467 A CN 202311091467A CN 117131851 A CN117131851 A CN 117131851A
Authority
CN
China
Prior art keywords
template
report
target
target template
file
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
CN202311091467.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.)
Fujian Boss Software Co ltd
Original Assignee
Fujian Boss Software Co ltd
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 Fujian Boss Software Co ltd filed Critical Fujian Boss Software Co ltd
Priority to CN202311091467.7A priority Critical patent/CN117131851A/en
Publication of CN117131851A publication Critical patent/CN117131851A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities

Abstract

The invention relates to a method for automatically generating a text version report, which comprises the following specific steps: creating a target template or importing a target template at the front end, wherein the template comprises a target template file and a parameter file; verifying the correctness of the target template at the client, returning error information by the error of the target template, generating a unique identifier if the target template is correct, and storing the target template in a back-end database; the method comprises the steps that a calling command is sent to a client from a front end, the client calls a target template and data parameters from a rear end database to analyze, a target report is generated through rendering, and a state code and a file stream of the target report are returned to the front end; the front end receives the status code, reads the returned target report file stream for previewing, and provides downloading modes with various formats.

Description

Method for automatically generating text version report
Technical Field
The invention relates to the technical field of information, in particular to a method for automatically generating a text version report.
Background
Today's report is very diverse in kind and number, and there are a wide variety of report forms, such as excel, word, pdf. Not only is a great deal of manpower required to write, but also the report is not easy to manage along with the increasing number of reports.
The existing reports are various in variety and number, and all the reports need to be written by people, so that great manpower resources are consumed. Many of these reporting formats are consistent, except that the content of the data changes, requiring manual replacement of the data by one item. Especially when the data content format to be changed is tables and charts, the tables and charts need to be manually re-made, which is particularly tedious. For example: for analysis of temperature changes of 1 to 12 months, each month corresponds to a report, and each report has the same content except for the change of data of each month, but the reports need to be replaced by each item manually, and a lot of unnecessary repeated work is more.
Disclosure of Invention
In order to solve the problems in the prior art, the invention provides a method for automatically generating a text report.
The technical scheme of the invention is as follows:
in one aspect, the present invention provides a method for automatically generating a text report, including the following specific steps:
creating a target template or importing a target template at the front end, wherein the template comprises a target template file and a parameter file;
verifying the correctness of the target template at the client, returning error information by the error of the target template, generating a unique identifier if the target template is correct, and storing the target template in a back-end database;
the method comprises the steps that a calling command is sent to a client from a front end, the client calls a target template and data parameters from a rear end database to analyze, a target report is generated through rendering, and a state code and a file stream of the target report are returned to the front end;
the front end receives the status code, reads the returned target report file stream for previewing, and provides downloading modes with various formats.
As a preferred embodiment, the client comprises a parsing engine, a rendering engine, a drawing engine, and a python parser; the analysis engine is used for analyzing the data issued by the front end and the data returned by the back end database; the rendering engine is used for drawing a report according to the result of the analysis engine; the drawing engine is used for drawing a final report according to the rendering result; the python parser is used for replacing parameter content of the drawn report.
As a preferred embodiment, the verifying, at the backend database, the correctness of the target template specifically includes:
for a target template file: verifying the correctness of the target template file through a python parser;
for the parameter file: firstly, checking the grammar correctness of the parameter file, and then checking whether the parameter file meets the preset writing rule.
As a preferred embodiment, the updating iteration of the target template is mainly performed by the following ways:
updating the template: creating a new template, verifying correctness at a background server, calling an updating interface of a back-end database, deleting an original template in the back-end database, storing the newly created template, and keeping an original unique identifier unchanged;
deleting the template: and calling a deleting interface of the back-end database from the front end, and deleting the template and the corresponding unique identifier in the back-end database.
As a preferred embodiment, the python parser is a modified third party library docxtpl that implements the insertion of dynamic tables and charts.
In another aspect, the present invention provides a system for automatically generating a text version report, comprising:
the template creation module creates a target template or imports the target template at the front end, wherein the template comprises a target template file and a parameter file;
the template verification module is used for verifying the correctness of the target template at the client, returning error information by the target template error, generating a unique identifier if the target template is correct, and storing the unique identifier into a back-end database;
the template rendering module is used for issuing a calling command from the front end to the client, the client invokes a target template and data parameters from the rear end database to analyze the target template and the data parameters, generating a target report through rendering, and returning a state code and a file stream of the target report to the front end;
and the report generating and downloading module reads the returned target report file stream to preview after the front end receives the status code and provides downloading modes with various formats.
As a preferred embodiment, the client comprises a parsing engine, a rendering engine, a drawing engine, and a python parser; the analysis engine is used for analyzing the data issued by the front end and the data returned by the back end database; the rendering engine is used for drawing a report according to the result of the analysis engine; the drawing engine is used for drawing a final report according to the rendering result; the python parser is used for replacing parameter content of the drawn report.
As a preferred embodiment, the verifying, at the backend database, the correctness of the target template specifically includes:
for a target template file: verifying the correctness of the target template file through a python parser;
for the parameter file: firstly, checking the grammar correctness of the parameter file, and then checking whether the parameter file meets the preset writing rule.
As a preferred embodiment, the updating iteration of the target template is mainly performed by the following ways:
updating the template: creating a new template, verifying correctness at a background server, calling an updating interface of a back-end database, deleting an original template in the back-end database, storing the newly created template, and keeping an original unique identifier unchanged;
deleting the template: and calling a deleting interface of the back-end database from the front end, and deleting the template and the corresponding unique identifier in the back-end database.
As a preferred embodiment, the python parser is a modified third party library docxtpl that implements the insertion of dynamic tables and charts.
The invention has the following beneficial effects:
1. the invention can rapidly process reports of the same template but different data, realizes batch processing of reports of the same type, and saves labor, financial resources and time.
2. The invention can realize the insertion of dynamic charts and tables in the report, makes up the inconvenience that only texts and pictures can be inserted in the prior art, and outputs the report result more intuitively.
3. The invention stores various report templates in the back-end database, each template corresponds to a unique identifier, and is directly called when in use, thereby being more convenient for report management with various types and numbers.
Drawings
FIG. 1 is a schematic flow chart of the present invention;
FIG. 2 is a schematic diagram of an overall flow of text version reporting according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an overall flow of report reporting according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a front-end report according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of template content according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of the parameter content according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of report generation according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the step numbers used herein are for convenience of description only and are not limiting as to the order in which the steps are performed.
It is to be understood that the terminology used in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
The terms "comprises" and "comprising" indicate the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
The term "and/or" refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Embodiment one:
referring to fig. 1, a method for automatically generating a text report includes the following specific steps:
creating a target template or importing a target template at the front end, wherein the template comprises a target template file and a parameter file;
verifying the correctness of the target template at the client, returning error information by the error of the target template, generating a unique identifier if the target template is correct, and storing the target template in a back-end database;
the method comprises the steps that a calling command is sent to a client from a front end, the client calls a target template and data parameters from a rear end database to analyze, a target report is generated through rendering, and a state code and a file stream of the target report are returned to the front end;
the front end receives the status code, reads the returned target report file stream for previewing, and provides downloading modes with various formats.
In this embodiment, the text report word is essentially a compressed file, and related content is drawn by various xml files, as shown in fig. 2, and the specific generation process is as follows:
when the front end stores the report template, a check interface of the client end is called, the report template is sent to the client end, after the client end receives the report template, a report template file path is sent to the python analyzer, whether the python analysis report template is filled in according to a specified rule and whether the filling format is correct or not is judged, if the check is successful, an excel parameter list in xml is returned to the client end in sequence, and the client end returns to the front end. The code field in the excel tag corresponds to the code of the front-end report template.
The front end is based on the returned excel parameter list, and the parameters which need to be issued to the client are pieced together. When exporting the report, the front end invokes the export report interface of the client and issues parameters to the client.
The client renders the report needed by the export report according to the issued parameters, generates an intermediate temporary file (excel file corresponding to each report) needed by report rendering, and issues the relevant path and the template of the temporary file to the python analyzer.
The python parser replaces placeholders in the template report with actual content of the report based on the template and the temporary file.
As a preferred implementation of this embodiment, the client includes a parsing engine, a rendering engine, a drawing engine, and a python parser; the analysis engine is used for analyzing the data issued by the front end and the data returned by the back end database; the rendering engine is used for drawing a report according to the result of the analysis engine; the drawing engine is used for drawing a final report according to the rendering result; the python parser is used for replacing parameter content of the drawn report.
In this embodiment, the python parser performs different substitutions according to different parameter file tags, and the specific substitution method is as follows:
for the cell tag, the python parser reads the corresponding cell content in the table according to the table drawn by the client, and replaces the cell content in the corresponding placeholder.
For an excel tag, the python parser reads the whole table including contents, patterns, row and column information and the like according to the table drawn by the client, and pieces up the contents into corresponding xml contents when word is inserted into the table, and then replaces the generated xml contents into corresponding placeholders.
For the chart tag, the python parser reads the contents of the table frame selection range according to the table drawn by the client, and the contents are pieced into corresponding xml contents when the word is inserted into the chart, and then the generated xml contents are replaced into the corresponding placeholders.
The parsing engine, the rendering engine and the drawing engine are all implemented by using QT language and are contained in a plugin named exportfile, the python parser is a python third party library docxtpl, and the exportfile plugin can call an interface of the python third party library docxtpl.
As a preferred implementation manner of this embodiment, the verifying, at the back-end database, the correctness of the target template specifically includes:
for a target template file: verifying the correctness of the target template file through a python parser;
for the parameter file: firstly, checking the grammar correctness of the parameter file, and then checking whether the parameter file meets the preset writing rule.
In this embodiment, the xsd and sch files are used to determine whether the xml file is filled in accordance with our specified rules.
As a preferred implementation manner of this embodiment, the updating iteration of the target template is mainly performed by the following manner:
updating the template: creating a new template, verifying correctness at a background server, calling an updating interface of a back-end database, deleting an original template in the back-end database, storing the newly created template, and keeping an original unique identifier unchanged;
deleting the template: and calling a deleting interface of the back-end database from the front end, and deleting the template and the corresponding unique identifier in the back-end database.
In this embodiment, the template is saved to the backend by uuid as a unique identifier.
As a preferred implementation of this example, the python parser is a modified third party library docxtpl that implements the insertion of dynamic tables and graphs.
In this embodiment, the original docxtpl library can only replace simple text content and pictures, but cannot be replaced by dynamic tables and charts, so that the docxtpl library is modified to a certain extent to be dynamically inserted into the tables and charts.
Embodiment two:
referring to fig. 3, a method for automatically generating a report includes the following steps:
firstly, a user opens a front-end page through a browser, clicks an export button, and the front-end invokes an interface of a client and issues parameters.
After the client receives the parameters sent by the front end, the parameters are analyzed, and the template and the floating data are requested from the back end.
And after the rear end receives the request, corresponding data is returned to the client according to the request parameters.
After receiving the data returned by the back end, the client analyzes and draws the data, generates a final file, and then returns the file stream to the front end.
After the front end receives the file stream returned by the client, operations such as previewing, downloading, printing and the like can be performed.
In the report generating method, each report designed at the front end has a unique identifier excelCode, the identifier is a template, and each report can display different data according to different parameter configurations.
For the automatic generation text report function, the front end provides a create template report and export text report button.
Wherein the template file is a word file, the fixed content is written in the template, and for the content needing to be replaced, the format of { { _id } } is used for replacing, for example: { _1 }. The template file is simply occupied, and what content is replaced by the template file is determined by the parameter file, wherein the id of the parameter file corresponds to the template file.
The parameter file is an xml file describing the content to be replaced. Substitution into tables, charts, cell content is supported, as well as loops and conditions. The parameter file is hidden in the word compression package, so that the safety of data is ensured.
The parameter file takes root as a root node, and child nodes support calculation formula results (add, sub, mul, div, and, or, eq, ne, ge, gt, le, lt), an insertion table (excel), replacement cell contents (cell), an insertion chart (chart), loops (loop) and conditions (condition).
The back end stores the template file and the parameter file.
The client is responsible for analyzing the template file and the parameter file to generate a final word.
One specific example is as follows:
fig. 4 shows a report of front-end design, fig. 5 shows a target template, fig. 6 shows a parameter file, and fig. 7 shows a report generated finally.
The excel with id=9 corresponds to the report designed at the front end, each report is provided with a unique code for identification, and the cell label refers to the content of replacing the cell.
The foregoing description is only illustrative of the present invention and is not intended to limit the scope of the invention, and all equivalent structures or equivalent processes or direct or indirect application in other related technical fields are included in the scope of the present invention.

Claims (10)

1. A method for automatically generating a text version report, comprising the steps of:
creating a target template or importing a target template at the front end, wherein the template comprises a target template file and a parameter file;
verifying the correctness of the target template at the client, returning error information by the error of the target template, generating a unique identifier if the target template is correct, and storing the target template in a back-end database;
the method comprises the steps that a calling command is sent to a client from a front end, the client calls a target template and data parameters from a rear end database to analyze, a target report is generated through rendering, and a state code and a file stream of the target report are returned to the front end;
the front end receives the status code, reads the returned target report file stream for previewing, and provides downloading modes with various formats.
2. The method of automatically generating a text version report of claim 1 wherein the client comprises a parsing engine, a rendering engine, a drawing engine, and a python parser; the analysis engine is used for analyzing the data issued by the front end and the data returned by the back end database; the rendering engine is used for drawing a report according to the result of the analysis engine; the drawing engine is used for drawing a final report according to the rendering result; the python parser is used for replacing parameter content of the drawn report.
3. The method for automatically generating a text version report according to claim 2, wherein the verifying the correctness of the target template in the back-end database specifically comprises:
for a target template file: verifying the correctness of the target template file through a python parser;
for the parameter file: firstly, checking the grammar correctness of the parameter file, and then checking whether the parameter file meets the preset writing rule.
4. A method of automatically generating a text version report according to claim 3 wherein the updating iteration of the target template is performed principally by:
updating the template: creating a new template, verifying correctness at a background server, calling an updating interface of a back-end database, deleting an original template in the back-end database, storing the newly created template, and keeping an original unique identifier unchanged;
deleting the template: and calling a deleting interface of the back-end database from the front end, and deleting the template and the corresponding unique identifier in the back-end database.
5. A method of automatically generating a literal report in accordance with claim 2 wherein said python parser is a modified third party library docxtpl that implements the insertion of dynamic tables and charts.
6. A system for automatically generating a text version report, comprising:
the template creation module creates a target template or imports the target template at the front end, wherein the template comprises a target template file and a parameter file;
the template verification module is used for verifying the correctness of the target template at the client, returning error information by the target template error, generating a unique identifier if the target template is correct, and storing the unique identifier into a back-end database;
the template rendering module is used for issuing a calling command from the front end to the client, the client invokes a target template and data parameters from the rear end database to analyze the target template and the data parameters, generating a target report through rendering, and returning a state code and a file stream of the target report to the front end;
and the report generating and downloading module reads the returned target report file stream to preview after the front end receives the status code and provides downloading modes with various formats.
7. The system for automatically generating a literal report in accordance with claim 6, wherein said client comprises a parsing engine, a rendering engine, a drawing engine, and a python parser; the analysis engine is used for analyzing the data issued by the front end and the data returned by the back end database; the rendering engine is used for drawing a report according to the result of the analysis engine; the drawing engine is used for drawing a final report according to the rendering result; the python parser is used for replacing parameter content of the drawn report.
8. The system for automatically generating a text version report according to claim 7, wherein the verifying the correctness of the target template in the back-end database comprises:
for a target template file: verifying the correctness of the target template file through a python parser;
for the parameter file: firstly, checking the grammar correctness of the parameter file, and then checking whether the parameter file meets the preset writing rule.
9. The system for automatically generating a literal report in accordance with claim 8, wherein said updating iteration of said target template is performed primarily by:
updating the template: creating a new template, verifying correctness at a background server, calling an updating interface of a back-end database, deleting an original template in the back-end database, storing the newly created template, and keeping an original unique identifier unchanged;
deleting the template: and calling a deleting interface of the back-end database from the front end, and deleting the template and the corresponding unique identifier in the back-end database.
10. A system for automatically generating a literal report in accordance with claim 7 wherein said python parser is a modified third party library docxtpl that implements the insertion of dynamic tables and charts.
CN202311091467.7A 2023-08-28 2023-08-28 Method for automatically generating text version report Pending CN117131851A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311091467.7A CN117131851A (en) 2023-08-28 2023-08-28 Method for automatically generating text version report

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311091467.7A CN117131851A (en) 2023-08-28 2023-08-28 Method for automatically generating text version report

Publications (1)

Publication Number Publication Date
CN117131851A true CN117131851A (en) 2023-11-28

Family

ID=88852277

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311091467.7A Pending CN117131851A (en) 2023-08-28 2023-08-28 Method for automatically generating text version report

Country Status (1)

Country Link
CN (1) CN117131851A (en)

Similar Documents

Publication Publication Date Title
EP1381945B1 (en) Method and system for reporting xml data based on precomputed context and a document object model
US6687873B1 (en) Method and system for reporting XML data from a legacy computer system
AU2001243470B2 (en) Method and system for modeling a legacy computer system
AU2001240068B2 (en) Method and system for applying XML schema
US7506324B2 (en) Enhanced compiled representation of transformation formats
US6742175B1 (en) Component-based source code generator
US20100088676A1 (en) Comparing and merging structured documents syntactically and semantically
AU2002257192A1 (en) Method and system for reporting XML data based on precomputed context and a document object model
US20040221233A1 (en) Systems and methods for report design and generation
AU2001242008A1 (en) Method and system for reporting XML data from a legacy computer system
US20040172592A1 (en) Importing and exporting markup language data in a spreadsheet application document
AU2001243470A1 (en) Method and system for modeling a legacy computer system
AU2001240068A1 (en) Method and system for applying XML schema
US8694957B2 (en) Method and apparatus for an XML reporter
Faulkner et al. HTML 5.2
US20080010588A1 (en) Document Processing Device and Document Processing Method
US20070061349A1 (en) Hierarchically describing shapes
US20080010587A1 (en) Document Processing Device and Document Processing Method
CA2347191A1 (en) Component-based source code generator
CN117131851A (en) Method for automatically generating text version report
US20080285064A1 (en) Document Processing Device, Document Processing Method, and Electronic Mail Processing Device
MXPA01003672A (en) Component-based source code generator

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