CN107590115B - Automatic Word report generation method and device - Google Patents

Automatic Word report generation method and device Download PDF

Info

Publication number
CN107590115B
CN107590115B CN201710825694.6A CN201710825694A CN107590115B CN 107590115 B CN107590115 B CN 107590115B CN 201710825694 A CN201710825694 A CN 201710825694A CN 107590115 B CN107590115 B CN 107590115B
Authority
CN
China
Prior art keywords
data
replacement
template
report
word
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.)
Active
Application number
CN201710825694.6A
Other languages
Chinese (zh)
Other versions
CN107590115A (en
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.)
Beijing Cesoft Corp ltd
Original Assignee
Beijing Cesoft Corp 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 Beijing Cesoft Corp ltd filed Critical Beijing Cesoft Corp ltd
Priority to CN201710825694.6A priority Critical patent/CN107590115B/en
Publication of CN107590115A publication Critical patent/CN107590115A/en
Application granted granted Critical
Publication of CN107590115B publication Critical patent/CN107590115B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A method for automatically generating a Word report comprises the steps that a user creates a report template file, a plurality of data substitutes are set in the report template file, a template data set and a substitute mapping are defined to form a Word report template, and parameters and a plurality of data replacement rules are further set for the Word report template; for a specified Word report template, after a parameter value is given, a data replacement rule of the specified Word report template is automatically converted into a database query statement and executed, so that data in a data source is obtained and a data replacement symbol on a report template file is replaced, and finally a Word report is formed; the invention provides a general solution for automatically generating the Word report by using the data existing in the information system, is suitable for any service field and various types of data sources, does not need to carry out interface development on the information system or the Word providing the data, and realizes the automatic generation of the Word report by zero coding.

Description

Automatic Word report generation method and device
Technical Field
The invention belongs to the fields of information systems, office automation and system integration, and particularly relates to a method and a device for automatically generating a Word report.
Background
During the daily work of enterprises and public institutions, reports in various word file forms, such as project feasibility reports, audit reports, work reports, marketing plans and the like, are often required to be made, and the reports usually contain various data and diagrams, which correspond to word statements. For the organization which has applied the management information system, the data needed in these reports often already exist in the information system, but there is not a better way to make the existing data in the information system conveniently available in the process of making Word reports; the data needed in the report is manually re-entered into the Word file, or exported to Excel or text file by using export function which may be provided by some information system, and copied and pasted into the Word file after being adjusted by proper editing and processing format, or the information system is directly developed for the second time, and the function of exporting the data into the Word file is specially added.
Disclosure of Invention
The invention provides a method and a device for automatically generating a Word report, which aim to solve the following problems: the data in the information system is directly embedded into the Word file, so that the automatic generation of the Word report is realized, and the method has the following three characteristics:
the method is simple: the data is directly embedded into the Word file without manual operation and data reprocessing;
general purpose: for Word files with any format, data with any content and format can be randomly embedded;
zero coding: the information system does not need to be developed for the second time, and extra programming work is not needed;
the present invention is described in detail below.
A Word report automatic generation method comprises the following steps:
step 1, a user specifies a data replacement symbol identification rule for identifying a data replacement symbol contained in a segment of text; the data replacement symbol is a character string which can appear in a section of characters and can be replaced by specific data contents; the data replacement character recognition rule specifies the characteristic of the data replacement character form, and the character string covering the characteristic can be recognized as the data replacement character;
step 2, a user creates a report template file; the report template file is a Word file, and the content of the report template file contains a data replacement symbol; all the data replacers in the report template file are replaced by specific data objects to obtain a Word file which is a specific Word report;
step 3, reading a report template file, identifying a data replacer in the report template file according to a data replacer identification rule, defining a template data set and a replacer mapping, combining the report template file, the template data set and the replacer mapping to form a Word report template, and storing the Word report template in a template library; the template data set specifies a data structure of data objects that can be used to replace data substitutes on a report template file, including one or more data tables that include one or more data items including data item names, data types; the said alternate mapping stipulates the corresponding relation between the data alternate and the template data set;
step 4, a user creates a data replacement rule set aiming at the Word report template and stores the data replacement rule set into a template library; the data replacement rule set comprises a parameter set and a plurality of data replacement rules; the set of parameters includes one or more parameters; the data replacement rule specifies a method for querying specific data in the data source and assigning values to the template data set; the parameter is a variable used in the data replacement rule; the data source is a carrier for storing data, and comprises a relational database, a non-relational database, a spreadsheet file, an Xml file, a Web service and/or a third-party system data interface;
step 5, starting the generation of the Word report, including specifying the Word report template to be used, and assigning the parameters in the parameter set of the data replacement rule set of the Word report template;
step 6, executing each data replacement rule in the data replacement rule set corresponding to the specified Word report template, acquiring data from a data source, and filling the data into the template data set;
and 7, replacing the data replacer on the report template file with the specific data in the template data set to form a specific Word report.
Preferably, the Word report template comprises a report generation mode; the report generation mode comprises manual starting generation, timing automatic generation and/or condition satisfaction generation;
preferably, the method for automatically generating the Word report comprises a single-value replacement, a multi-value replacement and/or a compound replacement;
the corresponding replacement symbol mapping of the single-value replacement symbol stipulates that the data replacement symbol corresponds to one data item in the template data set and can only be replaced by a specific value of the data item;
the multi-value replacement symbol corresponding to the multi-value replacement symbol is mapped and stipulated that the data replacement symbol corresponds to one data item in the template data set and can be replaced by a plurality of specific values of the data item;
the corresponding replacement mapping of the composite replacement symbol specifies the combination of a plurality of data items in the template data set corresponding to the data replacement symbol;
the result of the replacement of the multi-value placeholder by the plurality of specific values of the data item is that the plurality of specific values all appear on the replaced Word report.
Preferably, the method for automatically generating the Word report comprises the steps of data source, screening condition and filling mode; the data source comprises data tables in one or more databases; the screening condition is a filtering condition aiming at data in the data source; the population specifies how to assign data in the data source that satisfies the filter criteria to the template dataset.
Preferably, in the method for automatically generating a Word report, the step 6 specifically includes the following steps:
step 6.1, executing the following steps on all executable data replacement rules until all the executable data replacement rules are executed;
6.2, replacing variables in the screening conditions with parameter values, and translating the data replacement rules into executable database query statement sequences;
6.3, executing the database query statement sequence to obtain a data query result;
and 6.4, assigning values to the template data set by using the data query result according to the specification of the filling mode.
Preferably, in the method for automatically generating a Word report, the step 7 specifically includes: for all data substitutes on the Word report template, if the data substitutes are single-value substitutes, executing step 7.1, if the data substitutes are multi-value substitutes, executing step 7.2, and if the data substitutes are composite substitutes, executing step 7.3;
step 7.1, replacing the data replacement symbol on the report template file by the first specific value of the data item corresponding to the data replacement symbol in the template data set;
step 7.2, determining the value number n of the data item corresponding to the data replacement symbol in the template data set; copying n data replacers on the report template file, and replacing n data replacers with n values respectively;
step 7.3, a temporary table is formed by the values of each data item in the data item combination corresponding to the data replacement symbol, and the data replacement symbol on the report template file is replaced by the content of the temporary table;
the data replacer further includes a replacer pattern; the replacement symbol style specifies the representation form of the data replacement symbol on the report template file after being replaced by a specific data object; the replacement symbol pattern comprises a data item pattern and/or a data table pattern; the data item pattern is used for specifying the pattern of a single-value replacement symbol or a multi-value replacement symbol, and comprises a font, a color, a numerical value format, a date format, an alignment, a paragraph format and/or a numbering format; the data sheet style is used for specifying the style of the composite substitute, and comprises a sheet style, a chart style and/or a map style;
the step 7 further comprises:
and 7.4, modifying the specific data item value or the temporary table content of the report template file, which replaces the data replacement symbol, so that the report template file presents the appearance specified by the replacement symbol pattern.
A Word report automatic generation device comprises the following modules:
a replacement symbol recognition rule definition module, which is used for a user to specify a data replacement symbol recognition rule and is used for recognizing a data replacement symbol contained in a segment of characters; the data replacement symbol is a character string which can appear in a section of characters and can be replaced by specific data contents; the data replacement character recognition rule specifies the characteristic of the data replacement character form, and the character string covering the characteristic can be recognized as the data replacement character;
the report template editing module is used for creating a report template file by a user; the report template file is a Word file, and the content of the report template file contains a data replacement symbol; all the data replacers in the report template file are replaced by specific data objects to obtain a Word file which is a specific Word report;
the report template analysis module is used for reading the report template file, identifying the data replacer in the report template file according to the data replacer identification rule, defining a template data set and a replacer mapping, combining the report template file, the template data set and the replacer mapping to form a Word report template, and storing the Word report template in a template library; the template data set specifies a data structure of data objects that can be used to replace data substitutes on a report template file, including one or more data tables that include one or more data items including data item names, data types; the said alternate mapping stipulates the corresponding relation between the data alternate and the template data set;
the replacement rule configuration module is used for creating a data replacement rule set aiming at the Word report template by a user and storing the data replacement rule set into the template library; the data replacement rule set comprises a parameter set and a plurality of data replacement rules; the set of parameters includes one or more parameters; the data replacement rule specifies a method for querying specific data in the data source and assigning values to the template data set; the parameter is a variable used in the data replacement rule; the data source is a carrier for storing data, and comprises a relational database, a non-relational database, a spreadsheet file, an Xml file, a Web service and/or a third-party system data interface;
the report generation trigger is used for starting the generation of the Word report, and comprises the steps of appointing a Word report template to be used and assigning values to parameters in a parameter set of a data replacement rule set of the Word report template;
the rule execution module is used for executing each data replacement rule in the data replacement rule set corresponding to the specified Word report template, acquiring data from a data source and filling the data into the template data set;
and the data replacement module is used for replacing the data replacement symbol on the report template file with specific data in the template data set to form a specific Word report.
Preferably, the Word report template comprises a report generation mode; the report generation mode comprises manual starting generation, timing automatic generation and/or condition satisfaction generation;
preferably, the Word report automatic generation device comprises a single-value replacement character, a multi-value replacement character and/or a compound replacement character;
the corresponding replacement symbol mapping of the single-value replacement symbol stipulates that the data replacement symbol corresponds to one data item in the template data set and can only be replaced by a specific value of the data item;
the multi-value replacement symbol corresponding to the multi-value replacement symbol is mapped and stipulated that the data replacement symbol corresponds to one data item in the template data set and can be replaced by a plurality of specific values of the data item;
the corresponding replacement mapping of the composite replacement symbol specifies the combination of a plurality of data items in the template data set corresponding to the data replacement symbol;
the result of the replacement of the multi-value placeholder by the plurality of specific values of the data item is that the plurality of specific values all appear on the replaced Word report.
Preferably, the Word report automatic generation device, the data replacement rule includes a data source, a screening condition and a filling mode; the data source comprises data tables in one or more databases; the screening condition is a filtering condition aiming at data in the data source; the population specifies how to assign data in the data source that satisfies the filter criteria to the template dataset.
Preferably, the device for automatically generating a Word report includes:
the parameter replacement module is used for replacing variables in the screening conditions with parameter values and translating the data replacement rules into executable database query statement sequences;
the data query module is used for executing the database query statement sequence to obtain a data query result;
and the template data set assignment module is used for assigning the template data set with the data query result according to the specification of the filling mode.
Preferably, the device for automatically generating a Word report includes: the single-value placeholder replacing module is used for replacing the data replacement symbol on the report template file with the first specific value of the data item corresponding to the data replacement symbol in the template data set;
the multi-value placeholder replacing module is used for determining the value number n of the data item corresponding to the data replacer in the template data set; copying n data replacers on the report template file, and replacing n data replacers with n values respectively;
the composite placeholder replacing module is used for forming a temporary table by using the values of each data item in the data item combination corresponding to the data replacer and replacing the data replacer on the report template file by using the content of the temporary table;
the data replacer further includes a replacer pattern; the replacement symbol style specifies the representation form of the data replacement symbol on the report template file after being replaced by a specific data object; the replacement symbol pattern comprises a data item pattern and/or a data table pattern; the data item pattern is used for specifying the pattern of a single-value replacement symbol or a multi-value replacement symbol, and comprises a font, a color, a numerical value format, a date format, an alignment, a paragraph format and/or a numbering format; the data sheet style is used for specifying the style of the composite substitute, and comprises a sheet style, a chart style and/or a map style;
the data replacement module also comprises a placeholder modification module which is used for modifying the specific data item value or the temporary table content which replaces the data replacement on the report template file so as to lead the report template file to present the appearance specified by the replacement style.
Achieved technical effect
The scheme of the invention provides a general solution for automatically generating Word reports by utilizing data existing in an information system. Compared with the prior art, the scheme of the invention has the advantages that: universal, automatic and zero coding, described in detail below.
The universality is universality, namely the scheme of the invention can be suitable for any business field and is used for generating Word reports in any form and content;
first, the form of Word reports is ubiquitous. According to the scheme of the invention, a user creates a Word report which needs to be made in daily business into a Word file in advance, the Word file is called a report template file, a fixed character part of the Word file is directly written on the file, a dynamically variable data part is set as a data replacer, and a data structure required by generating the Word report and the attribute of data corresponding to each data replacer are specified by defining a template data set and mapping the data set with the replacer; the report template file, the template data set and the replacer mapping are integrated to form a Word report template;
secondly, the kind of data source used for generating data in the Word report is universal;
the Word report template is different from a common Word template (the concept of the Word itself), the common Word template only specifies the format of a Word file, the Word report template, except for specifying the format of the Word file, particularly specifies the data content which should be contained in the Word report template, and the characteristics of the organization structure, the value type, the incidence relation and the like of the data, and only the specific data which accords with the characteristics can be used for replacing the data replacer on the report template file to form a final Word report; however, the Word report template itself does not limit from which and how the data is obtained, and any data provider, including relational database, non-relational database, spreadsheet, Xml file, Web Service, information system interface API, public third party data Service API, etc., can be used as a data source for providing data to the Word report; different data replacers on the same report template file can also be replaced by data from different data sources, so that the data from different sources can be conveniently integrated into one report.
Thirdly, the method for acquiring the required data in the Word report is universal, and the execution is automatic;
how to obtain the required data in the Word report, the scheme of the invention is completed by setting and executing the data replacement rule; the data replacement rules specify which data is to be obtained from which data source, the filtering conditions required to obtain the data, and how to specifically replace the obtained data onto the report template file to form the desired Word report; the data replacement rule is an expression similar to natural language; the method is set by a user according to a what you see is what you get mode, so that various possible requirements and application scenes can be met, the execution of the method is automatically completed by a program, complex and error-prone manual operation is not needed, and the defect that other schemes need to be subjected to interface development is overcome.
A plurality of data replacement rules can be defined at will for a Word report template, different data replacement rules can use different data sources, so that data from different sources can be integrated into the same report, and the method is consistent and concise for complex application scenes that a plurality of information systems run in parallel or internal data of an enterprise and external three-party data need to be integrated at the same time.
Fourthly, as mentioned above, the process of extracting the data into the Word report is automatically completed, and meanwhile, the generation of the report can also be automated according to the requirements; according to the scheme of the invention, on the premise of setting the Word report template and the data replacement rule set, the Word report can be manually started and generated by a user, can also be automatically generated under the condition of meeting specific conditions or at certain intervals, is favorable for supporting various report systems and early warning systems of enterprises and public institutions, and further improves the efficiency.
In addition, the scheme of the invention not only supports the direct embodiment of the data content in the Word report, but also supports the display of the data content in the Word report in various change forms; by setting the style of the composite replacement symbol, the acquired corresponding data can be displayed in various forms of tables, charts and maps, so that the data can be more conveniently read by a report reader. The modification processing of the data display form is also automatically finished without user intervention, so that on one hand, a large amount of time of a user is saved, and on the other hand, the unified specification of format standards of various Word reports in an enterprise is facilitated.
Finally, IT is also the most important, each link of the scheme of the invention, all are "zero code", do not need to do any secondary development to the information system providing data, do not require to carry on the interface development to Word either, users create Word report template, just like editing a common Word file normally, define template data set, create data replacement rule, etc., all finish by seeing as if what is obtained, the whole course does not need any programming behavior, does not need IT technical staff to intervene, ordinary users can be competent at all.
The steps of the method of the present invention are not strictly fixed in time sequence.
Drawings
FIG. 1 is a schematic view of a report template file
FIG. 2 is a schematic diagram of a Word report obtained after the data replacement symbol on the report template file is replaced by the actual data
FIG. 3 is a schematic structural diagram of an automatic Word report generation apparatus
FIG. 4 is a data flow chart of a Word report automatic generation method
FIG. 5 is a flow chart of generating a Word report by executing a data replacement rule
FIG. 6 is a flow chart of the generation of a Word report by replacing data alternates on a Word report template with a template data set
Detailed Description
Report template file, data replacement symbol, template data set
FIG. 1 is an example of a report template file.
The user-specified data replacement identification rules are as follows:
using "<" and ">" as data substitute delimiters, i.e., "<. >" appearing in the file is a data substitute; the portion of each data replacement between "<" and ">" is in the form of n or n.m or x + y, where n, m, x, y all represent numbers; a single value of the replacement character in the form of n, and a multi-value of the replacement character in the form of n.m; a representation complex alternate in the form of x + y; if n parts of multiple multi-value substitutes n1.m1, n2.m2,. nn are all equal, i.e. n1 ═ n2 · ═ nn, their corresponding data items belong to the same data table in the template data set;
for example, in item Weekly, the following data substitutes are included:
Figure BSA0000150678110000081
Figure BSA0000150678110000091
for this report template file, there are the following template datasets
Figure BSA0000150678110000092
Fig. 2 is a schematic diagram of a Word report obtained by replacing the data replacement symbol in the report template file shown in fig. 1 with specific data in the template data set.
Data replacement rules
The Word report template specifies the uniform format of a certain type of report, and when the report is actually made, the data replacer in the report needs to be replaced by specific data. A method for how to replace the data replacement symbol with the specific data is a data replacement rule. For example, FIG. 1 shows a "project Weeking" template, which is submitted every Friday, so that the date of every Friday is a parameter; since there are multiple projects in progress, each with its own weekly report, the project name is also needed as another parameter.
The data replacement rule is used for extracting data in the data source according to the input parameters, filling the template data set, further replacing data replacement symbols on the report template file, and generating a Word report.
The preconditions required for defining the data replacement rules are: there are available data sources, typically databases of an information system, and the data structures in the data sources are known.
The data replacement rule consists of three parts: data source, screening condition and filling mode;
the data source refers to a table or a view in the database of the information system, the screening condition is a filtering condition aiming at the data in the data source, wherein parameters are used, and the filling mode specifies how to fill the extracted data into the template data set.
For example, the following is a data replacement rule associated with the project Weekly template:
data satisfying the following conditions in the "project plan" is extracted:
screening conditions are as follows:
project plan, project name ═ input parameter project name
And project plan completion time < ═ input parameter report date
And project plan complete time ═ input parameter, report date-7
Fill in "completion of week":
project plan, task- -complete this week
Project plan completion time- -completion of the week and plan completion time
Project plan completion time-completion time of this week
Project plan, explain- -complete this week, complete
After obtaining the values of the input parameters, the data replacement rules are "instantiated" as database query statements, the query is executed to obtain a result record set, and the result record set is assigned to the template data set according to the specification of the filling mode, for example, the following is the database query statements after the data replacement rules are instantiated:
select task, plan completion time, description
from completion of week
where project name is 'comprehensive budget management System'
and completion time < ═ 2017-07-05'
and completion time ═ dated (d, -7, '2017-07-05')
Device for measuring the position of a moving object
FIG. 3 is a schematic structural diagram of an automatic Word report generation apparatus.
The apparatus comprises a template configurator 301, a template library 302 and a report generator 303;
wherein the template configurator 301 comprises a replacement identifier identification rule definition module 311, a report template editing module 312, a report template analysis module 313 and a replacement rule configuration module 314;
a replacement identifier identification rule definition module 311, configured to specify a data replacement identifier identification rule by a user, and identify a data replacement identifier included in a segment of text; the data replacement symbol is a character string which can appear in a section of characters and can be replaced by specific data contents; the data replacement character recognition rule specifies the characteristic of the data replacement character form, and the character string covering the characteristic can be recognized as the data replacement character;
a report template editing module 312 for a user to create a report template file; the report template file is a Word file, and the content of the report template file contains a data replacement symbol; all the data replacers in the report template file are replaced by specific data objects to obtain a Word file which is a specific Word report;
the report template analysis module 313 is used for reading the report template file, identifying the data replacer according to the data replacer identification rule, defining a template data set and a replacer mapping, combining the report template file, the template data set and the replacer mapping to form a Word report template, and storing the Word report template in the template library 302; the template data set specifies a data structure of data objects that can be used to replace data substitutes on a report template file, including one or more data tables that include one or more data items including data item names, data types; the said alternate mapping stipulates the corresponding relation between the data alternate and the template data set;
the replacement rule configuration module 314 is used for creating a data replacement rule set aiming at the Word report template by a user and storing the data replacement rule set into a template library; the data replacement rule set comprises a parameter set and a plurality of data replacement rules; the set of parameters includes one or more parameters; the data replacement rule specifies a method for querying specific data in the data source and assigning values to the template data set; the parameter is a variable used in the data replacement rule; the data source is a carrier for storing data, and comprises a relational database, a non-relational database, a spreadsheet file, an Xml file, a Web service and/or a third-party system data interface;
the report generator 303 includes a report generation trigger 331, a rule execution module 332, and a data replacement module 333;
the report generation trigger 331 is used for starting the generation of the Word report, and comprises the steps of specifying a Word report template to be used and assigning values to parameters in a parameter set of a data replacement rule set of the Word report template;
the rule execution module 332 is configured to execute each data replacement rule in the data replacement rule set corresponding to the specified Word report template, acquire data from the data source 304, and fill the data in the template data set;
and the data replacement module 333 is used for replacing the data replacer on the report template file with the specific data in the template data set to form a specific Word report.
Method flow
FIG. 4 is a data flow diagram of a method for automatically generating a Word report.
Step 401, a user specifies a data replacement identifier identification rule for identifying a data replacement identifier included in a segment of text; the data replacement symbol is a character string which can appear in a section of characters and can be replaced by specific data contents; the data replacement character recognition rule specifies the characteristic of the data replacement character form, and the character string covering the characteristic can be recognized as the data replacement character;
step 402, a user creates a report template file to generate a report template file 403; the report template file 403 is a Word file, and the content of the report template file contains data substitutes; the Word file obtained after all the data substitutes in the report template file 403 are replaced by specific data objects is a specific Word report
Step 404, analyzing a report template file; reading a report template file 403, identifying a data replacer therein according to a data replacer identification rule, defining a template data set and a replacer mapping 405, combining the report template file 403, the template data set and the replacer mapping 405 to form a Word report template, and storing the Word report template in a template library 406; the template data set specifies a data structure of data objects that can be used to replace data substitutes on a report template file, including one or more data tables that include one or more data items including data item names, data types; the said alternate mapping stipulates the corresponding relation between the data alternate and the template data set;
step 407, the user creates a data replacement rule set 409 aiming at the Word report template and stores the data replacement rule set in the template library 406; the data replacement rule set 409 comprises a parameter set and a plurality of data replacement rules; the set of parameters includes one or more parameters; the data replacement rule specifies a method for querying specific data in the data source and assigning values to the template data set; the parameter is a variable used in the data replacement rule; the data source is a carrier for storing data, and comprises a relational database, a non-relational database, a spreadsheet file, an Xml file, a Web service and/or a third-party system data interface; the data source is an information carrier which can provide data required by Word report, and is usually an information system database; creating the data replacement rule requires prior knowledge of the information system data structure 408;
step 410, starting the generation of the Word report, including specifying the Word report template to be used, and assigning values to the parameters in the parameter set of the data replacement rule set of the Word report template; the step can be started manually by a user or automatically at regular time according to a preset plan; in this step, another copy file 411 is stored in the report template file 403 for data replacement;
step 412, executing each data replacement rule in the data replacement rule set 409 corresponding to the specified Word report template, acquiring data from a data source, filling the data into the template data set, and obtaining an assigned template data set 413;
in step 414, the data replacement symbol on the report template file copy 411 is replaced with the specific data in the copied template data set 413, and a specific Word report 415 is formed.
FIG. 5 is a flow chart of generating a Word report by executing a data replacement rule
Step 501, reading a specified Word report template and a corresponding data replacement rule set from a template library;
step 502, obtaining a parameter value;
step 503, initializing a template data set;
step 504, if all the data replacement rules in the data replacement rule set have been processed, go to step 509, otherwise continue step 505;
step 505, taking out the first unprocessed data replacement rule in the data replacement rule set, and referring to the data replacement rule by r in the following steps for concise line;
step 506, converting r into an executable database query statement by combining the parameter values;
step 507, executing database query statements to obtain a result record set;
step 508, assigning values to the template data set by the result record set; marking the data replacement rule r as having been processed; turning to step 504;
and 509, replacing the data replacer on the report template file with the data in the template data set to generate a final Word report.
FIG. 6 is a flow chart for generating a Word report by replacing data substitutes on a report template file with a template data set.
601, if the report template file still has the data replacer which is not replaced, continuing the following steps, otherwise, ending;
step 602, determining a next data replacement to be processed, wherein the data replacement is referred to by x in the following steps for brevity of a line;
step 603, judging the type of x, and if x is a single-value replacer, turning to step 604; if x is a multi-valued replacement symbol, go to step 606; if x is the composite replacement symbol, go to step 609;
step 604, determining a first value v of the data item corresponding to x in the template data set;
step 605, replace x on the report template file with v; turning to step 612;
step 606, determining the value number n of the data item corresponding to x in the template data set;
step 607, copying x on the report template file by n;
step 608, sequentially replacing n x values on the report template file with n values of the data items corresponding to x; turning to step 612;
step 609, forming a temporary table by all data items in the data item combination corresponding to the x;
step 610, assigning a value to the temporary table according to the value of each data item in the template data set;
step 611, replace x on the report template file with the temporary table data;
step 612, rendering the data with x replaced by the replacement character pattern of x, and then returning to step 601.

Claims (10)

1. A Word report automatic generation method is characterized by comprising the following steps:
step 1, a user specifies a data replacement symbol identification rule for identifying a data replacement symbol contained in a segment of text; the data replacement symbol is a character string which appears in a section of characters and can be replaced by specific data contents; the data replacement character recognition rule specifies a characteristic in the form of a data replacement character, and a character string conforming to the characteristic can be recognized as the data replacement character;
step 2, a user creates a report template file; the report template file is a Word file, and the content of the report template file contains a data replacement symbol; all the data replacers in the report template file are replaced by specific data objects to obtain a Word file which is a specific Word report;
step 3, reading a report template file, identifying a data replacer in the report template file according to a data replacer identification rule, defining a template data set and a replacer mapping, combining the report template file, the template data set and the replacer mapping to form a Word report template, and storing the Word report template in a template library; the template data set specifies a data structure of data objects that can be used to replace data substitutes on a report template file, including one or more data tables that include one or more data items including data item names, data types; the said alternate mapping stipulates the corresponding relation between the data alternate and the template data set;
step 4, a user creates a data replacement rule set aiming at the Word report template and stores the data replacement rule set into a template library; the data replacement rule set comprises a parameter set and a plurality of data replacement rules; the set of parameters includes one or more parameters; the data replacement rule specifies a method for querying specific data in the data source and assigning values to the template data set; the parameter is a variable used in the data replacement rule; the data source is a carrier for storing data, and comprises a relational database, a non-relational database, a spreadsheet file, an Xml file, a Web service and/or a third-party system data interface;
step 5, starting the generation of the Word report, including specifying the Word report template to be used, and assigning the parameters in the parameter set of the data replacement rule set of the Word report template;
step 6, executing each data replacement rule in the data replacement rule set corresponding to the specified Word report template, acquiring data from a data source, and filling the data into the template data set;
and 7, replacing the data replacer on the report template file with the specific data in the template data set to form a specific Word report.
2. The automatic Word report generating method according to claim 1,
the data replacement symbol comprises a single-value replacement symbol, a multi-value replacement symbol and/or a composite replacement symbol;
the corresponding replacement symbol mapping of the single-value replacement symbol stipulates that the data replacement symbol corresponds to one data item in the template data set and can only be replaced by a specific value of the data item;
the multi-value replacement symbol corresponding to the multi-value replacement symbol is mapped and stipulated that the data replacement symbol corresponds to one data item in the template data set and can be replaced by a plurality of specific values of the data item;
the composite replacement symbol, the corresponding replacement symbol mapping specifying that the data replacement symbol corresponds to a combination of data items in the template data set.
3. The automatic Word report generating method according to claim 1, wherein the data replacement rule includes data source, filtering condition and filling mode; the data source comprises data tables in one or more databases; the screening condition is a filtering condition aiming at data in the data source; the population specifies how to assign data in the data source that satisfies the filter criteria to the template dataset.
4. The automatic Word report generating method according to claim 3, wherein the step 6 specifically comprises the steps of:
step 6.1, executing the following steps on all executable data replacement rules until all the executable data replacement rules are executed;
step 6.2, replacing variables in the screening conditions with parameter values, translating the data replacement rules into executable database query statement sequences,
6.3, executing the database query statement sequence to obtain a data query result;
and 6.4, assigning values to the template data set by using the data query result according to the specification of the filling mode.
5. The automatic Word report generating method according to claim 2, wherein the step 7 specifically comprises:
for all data substitutes on the Word report template, if the data substitutes are single-value substitutes, executing step 7.1, if the data substitutes are multi-value substitutes, executing step 7.2, and if the data substitutes are composite substitutes, executing step 7.3;
step 7.1, replacing the data replacement symbol on the report template file by the first specific value of the data item corresponding to the data replacement symbol in the template data set;
step 7.2, determining the value number n of the data item corresponding to the data replacement symbol in the template data set; copying n data replacers on the report template file, and replacing n data replacers with n values respectively;
step 7.3, a temporary table is formed by the values of each data item in the data item combination corresponding to the data replacement symbol, and the data replacement symbol on the report template file is replaced by the content of the temporary table;
the data replacer further includes a replacer pattern; the replacement symbol style specifies the representation form of the data replacement symbol on the report template file after being replaced by a specific data object; the replacement symbol pattern comprises a data item pattern and/or a data table pattern; the data item pattern is used for specifying the pattern of a single-value replacement symbol or a multi-value replacement symbol, and comprises a font, a color, a numerical value format, a date format, an alignment, a paragraph format and/or a numbering format; the data sheet style is used for specifying the style of the composite substitute, and comprises a sheet style, a chart style and/or a map style;
said step 7 further comprises the step of,
and 7.4, modifying the specific data item value or the temporary table content of the report template file, which replaces the data replacement symbol, so that the report template file presents the appearance specified by the replacement symbol pattern.
6. The automatic generating device of the Word report is characterized by comprising the following modules:
a replacement symbol recognition rule definition module, which is used for a user to specify a data replacement symbol recognition rule and is used for recognizing a data replacement symbol contained in a segment of characters; the data replacement symbol is a character string which appears in a section of characters and can be replaced by specific data contents; the data replacement character recognition rule specifies a characteristic in the form of a data replacement character, and a character string conforming to the characteristic can be recognized as the data replacement character;
the report template editing module is used for creating a report template file by a user; the report template file is a Word file, and the content of the report template file contains a data replacement symbol; all the data replacers in the report template file are replaced by specific data objects to obtain a Word file which is a specific Word report;
the report template analysis module is used for reading the report template file, identifying the data replacer in the report template file according to the data replacer identification rule, defining a template data set and a replacer mapping, combining the report template file, the template data set and the replacer mapping to form a Word report template, and storing the Word report template in a template library; the template data set specifies a data structure of data objects that can be used to replace data substitutes on a report template file, including one or more data tables that include one or more data items including data item names, data types; the said alternate mapping stipulates the corresponding relation between the data alternate and the template data set;
the replacement rule configuration module is used for creating a data replacement rule set aiming at the Word report template by a user and storing the data replacement rule set into the template library; the data replacement rule set comprises a parameter set and a plurality of data replacement rules; the set of parameters includes one or more parameters; the data replacement rule specifies a method for querying specific data in the data source and assigning values to the template data set; the parameter is a variable used in the data replacement rule; the data source is a carrier for storing data, and comprises a relational database, a non-relational database, a spreadsheet file, an Xml file, a Web service and/or a third-party system data interface;
the report generation trigger is used for starting the generation of the Word report, and comprises the steps of appointing a Word report template to be used and assigning values to parameters in a parameter set of a data replacement rule set of the Word report template;
the rule execution module is used for executing each data replacement rule in the data replacement rule set corresponding to the specified Word report template, acquiring data from a data source and filling the data into the template data set;
and the data replacement module is used for replacing the data replacement symbol on the report template file with specific data in the template data set to form a specific Word report.
7. A Word report automatic generation device according to claim 6, characterized in that said data replacement characters include single value replacement characters, multi-value replacement characters and/or composite replacement characters;
the corresponding replacement symbol mapping of the single-value replacement symbol stipulates that the data replacement symbol corresponds to one data item in the template data set and can only be replaced by a specific value of the data item;
the multi-value replacement symbol corresponding to the multi-value replacement symbol is mapped and stipulated that the data replacement symbol corresponds to one data item in the template data set and can be replaced by a plurality of specific values of the data item;
the composite replacement symbol, the corresponding replacement symbol mapping specifying that the data replacement symbol corresponds to a combination of data items in the template data set.
8. The automatic Word report generating device according to claim 6, wherein the data replacement rules include data source, filtering condition and filling mode; the data source comprises data tables in one or more databases; the screening condition is a filtering condition aiming at data in the data source; the population specifies how to assign data in the data source that satisfies the filter criteria to the template dataset.
9. The automatic Word report generating device according to claim 8, wherein the rule executing module specifically comprises:
the parameter replacement module is used for replacing variables in the screening conditions with parameter values and translating the data replacement rules into executable database query statement sequences;
the data query module is used for executing the database query statement sequence to obtain a data query result;
and the template data set assignment module is used for assigning the template data set with the data query result according to the specification of the filling mode.
10. The automatic Word report generating device according to claim 7, wherein the data replacement module specifically comprises: the single-value placeholder replacing module is used for replacing the data replacement symbol on the report template file with the first specific value of the data item corresponding to the data replacement symbol in the template data set;
the multi-value placeholder replacing module is used for determining the value number n of the data item corresponding to the data replacer in the template data set; copying n data replacers on the report template file, and replacing n data replacers with n values respectively;
the composite placeholder replacing module is used for forming a temporary table by using the values of each data item in the data item combination corresponding to the data replacer and replacing the data replacer on the report template file by using the content of the temporary table;
the data replacer further includes a replacer pattern; the replacement symbol style specifies the representation form of the data replacement symbol on the report template file after being replaced by a specific data object; the replacement symbol pattern comprises a data item pattern and/or a data table pattern; the data item pattern is used for specifying the pattern of a single-value replacement symbol or a multi-value replacement symbol, and comprises a font, a color, a numerical value format, a date format, an alignment, a paragraph format and/or a numbering format; the data sheet style is used for specifying the style of the composite substitute, and comprises a sheet style, a chart style and/or a map style;
the data replacement module also comprises a placeholder modification module which is used for modifying the specific data item value or the temporary table content which replaces the data replacement on the report template file so as to lead the report template file to present the appearance specified by the replacement style.
CN201710825694.6A 2017-09-13 2017-09-13 Automatic Word report generation method and device Active CN107590115B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710825694.6A CN107590115B (en) 2017-09-13 2017-09-13 Automatic Word report generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710825694.6A CN107590115B (en) 2017-09-13 2017-09-13 Automatic Word report generation method and device

Publications (2)

Publication Number Publication Date
CN107590115A CN107590115A (en) 2018-01-16
CN107590115B true CN107590115B (en) 2020-08-11

Family

ID=61051963

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710825694.6A Active CN107590115B (en) 2017-09-13 2017-09-13 Automatic Word report generation method and device

Country Status (1)

Country Link
CN (1) CN107590115B (en)

Families Citing this family (30)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108197095A (en) * 2018-01-30 2018-06-22 南京焦点领动云计算技术有限公司 A kind of word template generation methods based on poi
CN110196966B (en) * 2018-02-27 2020-12-29 北大方正集团有限公司 Method and device for identifying group pictures in Word document
CN108595397A (en) * 2018-04-09 2018-09-28 重庆塞尔特科技有限公司 A method of automatically generating report
CN108595399B (en) * 2018-04-16 2021-08-10 北京航空航天大学 Artificial intelligence generation method for digital aircraft simulation research budget table
CN108647196B (en) * 2018-04-16 2022-10-25 北京航空航天大学 Artificial intelligence generation method and device for table in digital aircraft simulation report
CN108920439A (en) * 2018-06-14 2018-11-30 浙江省水利河口研究院 A method of automatically generating geological mapping report rock-soil layer description
CN109299446B (en) * 2018-08-03 2022-08-12 新华三大数据技术有限公司 Report generation method and device
CN109255112A (en) * 2018-08-29 2019-01-22 中国信息通信研究院 A kind of report automatic generation method and system
CN110969003A (en) * 2018-09-29 2020-04-07 北京国双科技有限公司 Text content generation method and device
CN109657217A (en) * 2018-11-20 2019-04-19 北京天威诚信电子商务服务有限公司 Report-generating method, device and electronic equipment
CN111353611B (en) * 2018-12-20 2023-05-26 核动力运行研究所 Nuclear power station in-service inspection large repair inspection report automatic generation system and method
CN110148048A (en) * 2019-03-28 2019-08-20 翼帆数字科技(南京)有限公司 A kind of bank confirmation request management method based on block chain technology
CN110309499B (en) * 2019-07-05 2020-07-17 广东铭太信息科技有限公司 Device for generating examination report and method for generating examination report online
CN110309498B (en) * 2019-07-05 2020-10-16 广东铭太信息科技有限公司 Method and device for generating audit report based on parameters and method for generating audit report by using same
CN110738038A (en) * 2019-10-23 2020-01-31 泰康保险集团股份有限公司 Contract text generation method, device, equipment and computer readable storage medium
CN111145051A (en) * 2019-11-26 2020-05-12 方正璞华软件(武汉)股份有限公司 Method and device for generating arbitration electronic document
CN110968997B (en) * 2019-12-03 2023-07-21 广联达科技股份有限公司 Strong controllable document generation method and device, storage medium and electronic equipment
CN111178026A (en) * 2019-12-05 2020-05-19 北京直真科技股份有限公司 Method for realizing operation analysis report of special line for collecting passenger
CN113128189A (en) * 2019-12-30 2021-07-16 东软集团(上海)有限公司 Office commonly-used phrase recording method and device
CN111313958A (en) * 2020-02-12 2020-06-19 深圳航天宏图信息技术有限公司 Satellite data quality inspection report generation system
CN112364617B (en) * 2020-10-29 2024-07-30 北京新锦成科技有限公司 File information processing method and device, electronic equipment and storage medium
CN112560420A (en) * 2020-12-08 2021-03-26 中国建设银行股份有限公司 Method and device for automatically generating report file
CN112581247A (en) * 2020-12-24 2021-03-30 中国建设银行股份有限公司 Financial report generation method and device
CN113240392A (en) * 2021-05-17 2021-08-10 远光软件股份有限公司 Report generation method and system based on robot process automation
CN113822037B (en) * 2021-11-23 2022-04-26 深圳逻辑汇科技有限公司 Method, device, equipment and medium for inserting placeholder and generating data mapping table
CN115310413B (en) * 2022-04-13 2023-07-18 北京梦天门科技股份有限公司 Epidemiological investigation report generation method, epidemiological investigation report generation device, storage medium and electronic equipment
CN115080586A (en) * 2022-05-10 2022-09-20 兴业银行股份有限公司 Method and system for automatically generating report document from data
CN115270748B (en) * 2022-07-25 2023-05-23 中化现代农业有限公司 File generation method, device, electronic equipment and storage medium
CN116227454A (en) * 2023-02-28 2023-06-06 易方达基金管理有限公司 Universal automatic report generation method and system
CN116089570A (en) * 2023-04-07 2023-05-09 北京大学深圳研究生院 Report generation method, device, system and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101216849A (en) * 2008-01-11 2008-07-09 清华大学 Document automatic creation method based on integration business model
US8176412B2 (en) * 2009-08-25 2012-05-08 International Business Machines Corporation Generating formatted documents
CN104572597A (en) * 2015-01-12 2015-04-29 浪潮通用软件有限公司 Automatic word analysis report generation method and device
CN106339363A (en) * 2015-07-07 2017-01-18 北京神州泰岳软件股份有限公司 PPT report making method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130212474A1 (en) * 2011-02-16 2013-08-15 Cynthia K. McCAHON Computer-implemented system and method for facilitating creation of business plans and reports

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101216849A (en) * 2008-01-11 2008-07-09 清华大学 Document automatic creation method based on integration business model
US8176412B2 (en) * 2009-08-25 2012-05-08 International Business Machines Corporation Generating formatted documents
CN104572597A (en) * 2015-01-12 2015-04-29 浪潮通用软件有限公司 Automatic word analysis report generation method and device
CN106339363A (en) * 2015-07-07 2017-01-18 北京神州泰岳软件股份有限公司 PPT report making method and device

Also Published As

Publication number Publication date
CN107590115A (en) 2018-01-16

Similar Documents

Publication Publication Date Title
CN107590115B (en) Automatic Word report generation method and device
CN108090073B (en) Configurable bill of material conversion method and device
CN107783949B (en) PPT document processing method and device
CN105528418B (en) A kind of design documentation generation method and device
CN111061733B (en) Data processing method, device, electronic equipment and computer readable storage medium
CN111191125A (en) Data analysis method based on tagging
CN112016287B (en) Data management method, platform, storage medium and electronic equipment
CN112883692B (en) Automatic generation method of PPT data report
CN110866024B (en) Vector database increment updating method and system
WO2023241519A1 (en) Bim component creation method and apparatus, and digital design resource library application method and apparatus
CN115858810A (en) Method, system, computer device and storage medium for automatically constructing knowledge graph
CN109241515B (en) Method and device for generating report file
CN110806977A (en) Test case set generation method and device based on product requirements and electronic equipment
US11222174B2 (en) Systems and methods for generating logical documents for a document evaluation system
CN111143356B (en) Report retrieval method and device
CN110502735B (en) Method and system for quickly manufacturing universal process file of electronic equipment
CN111143353B (en) Method for extracting BOM change data from change list
CN109976719B (en) Design method of management system, electronic equipment, storage medium and platform
CN114895875B (en) Zero-code visual information system metadata production application method and system
CN108205564B (en) Knowledge system construction method and system
CN116204509A (en) Data access script generation method and device, electronic equipment and storage medium
CN114862334A (en) Design method of intelligent contract examination rule configuration platform
CN116956837A (en) Project determining method and device for engineering quantity list
CN113254455A (en) Dynamic configuration method and device of database, computer equipment and storage medium
CN114118026A (en) Automatic document generation method and device, computer storage medium and electronic equipment

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
GR01 Patent grant
GR01 Patent grant