Document generation method, device, electronic device and computer-readable storage medium

By using the combination of XML format and template engine in Excel documents, the blank lines are automatically filled, which solves the problem of time-consuming manual input of information in the prior art, improves the efficiency of Excel document generation and reduces costs.

CN114330268BActive Publication Date: 2024-12-03BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111499422.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2024-12-03
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

In the prior art, manually entering object attribute information in Excel documents requires a large labor cost, resulting in low efficiency in generating Excel documents.

Method used

By obtaining XML-formatted documents, replacing the specified character area with loop expressions and ending characters, and automatically filling blank lines with the preset template engine to generate the final Excel document, improving document generation efficiency and reducing labor costs.

Benefits of technology

Automatic loop filling of blank lines is realized, which improves the efficiency of Excel document generation, reduces labor costs, avoids manual input errors, and improves the maintainability of template documents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114330268B_ABST
    Figure CN114330268B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a document generation method, device, electronic device and computer-readable storage medium, which relates to the field of computer technology. The method includes: obtaining a first document in XML format; the first document is obtained by format conversion of a second document in Excel format containing blank lines to be filled; a loop expression is recorded on the upper side of the blank line in the second document, and a terminator is recorded on the lower side; in the first document, the previous line of the designated character area is replaced with the loop expression in the previous line, and the next line of the designated character area is replaced with the terminator in the next line to obtain a third document; the designated character area represents the blank line to be filled; based on a preset template engine, the third document and the first data to be filled into the blank line are combined to obtain a final fourth document; the table contained in the fourth document is filled with the first data. It can improve the efficiency of Excel document generation and reduce labor costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a document generation method, device, electronic equipment and computer-readable storage medium. Background Art

[0002] With the rapid development of computer technology, users can record information based on electronic documents. For example, a hospital can use Excel documents to count patient information, and a teacher can use Excel documents to count student grades. In one implementation, in an Excel document, each row of a table represents an object, and each row of a table can record multiple attribute information of the object.

[0003] In the related art, manually inputting the attribute information of each object into a table of an Excel document requires a large labor cost and results in a low efficiency in generating the Excel document. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a document generation method, device, electronic device and computer-readable storage medium to improve the efficiency of Excel document generation and reduce labor costs. The specific technical solution is as follows:

[0005] In a first aspect of the present invention, a document generation method is provided, the method comprising:

[0006] Acquire a first document in XML (Extensible Markup Language) format; wherein the first document is obtained by converting a second document in Excel format containing blank rows to be filled; a loop expression is recorded on the upper side of the blank row in the second document, and a terminator is recorded on the lower side;

[0007] In the first document, a line before the designated character region is replaced with a loop expression in the previous line, and a line after the designated character region is replaced with a terminator in the latter line, to obtain a third document; wherein the designated character region represents the blank line to be filled;

[0008] Based on a preset template engine, the third document and the first data to be filled into the blank row are combined to obtain a final fourth document; wherein the table included in the fourth document is filled with the first data.

[0009] Optionally, the template engine is a Velocity template engine or a Freemarker template engine.

[0010] Optionally, the combining of the third document and the first data to be filled into the blank row based on a preset template engine to obtain a final fourth document includes:

[0011] Based on a preset template engine, the third document and the first data to be filled into the blank row are combined to obtain a fifth document in XML format; the table included in the fifth document is filled with the first data;

[0012] Counting the number of data rows recorded in the fifth document as a target value;

[0013] Modify the variable representing the number of data rows in the fifth document to the target value to obtain a sixth document;

[0014] Based on the sixth document, a fourth document in Excel format is obtained.

[0015] Optionally, the third document and the first data to be filled into the blank row are combined based on a preset template engine to obtain a fifth document in XML format, including:

[0016] Based on a preset template engine, for each attribute information belonging to the same row in the first data to be filled into the blank row, values ​​are sequentially assigned to corresponding variables in the designated character area in the third document to obtain a fifth document in XML format.

[0017] Optionally, obtaining a fourth document in Excel format based on the sixth document includes:

[0018] The document format of the sixth document is modified into Excel format to obtain a fourth document.

[0019] Optionally, obtaining the first document in XML format includes:

[0020] Acquire a seventh document in XML format obtained by format conversion of the second document;

[0021] The seventh document is formatted to obtain a first document.

[0022] In a second aspect of the present invention, a document generation device is provided, the device comprising:

[0023] A first document acquisition module is used to acquire a first document in an extensible markup language XML format; wherein the first document is obtained by formatting a second document in an Excel format containing blank rows to be filled; a loop expression is recorded on the upper side of the blank row in the second document, and a terminator is recorded on the lower side;

[0024] A third document acquisition module is used to replace the previous line of the designated character area with the loop expression in the previous line, and replace the next line of the designated character area with the terminator in the next line, in the first document, to obtain a third document; wherein the designated character area represents the blank line to be filled;

[0025] The fourth document acquisition module is used to combine the third document and the first data to be filled into the blank row based on a preset template engine to obtain a final fourth document; wherein the table contained in the fourth document is filled with the first data.

[0026] Optionally, the template engine is a Velocity template engine or a Freemarker template engine.

[0027] Optionally, the fourth document acquisition module includes:

[0028] A fifth document acquisition submodule, configured to combine the third document and the first data to be filled into the blank row based on a preset template engine to obtain a fifth document in XML format; the table included in the fifth document is filled with the first data;

[0029] A target value acquisition submodule, used for counting the number of data rows recorded in the fifth document as a target value;

[0030] A modification submodule, used for modifying the variable representing the number of data rows in the fifth document to the target value, so as to obtain a sixth document;

[0031] The fourth document acquisition submodule is used to obtain a fourth document in Excel format based on the sixth document.

[0032] Optionally, the fifth document acquisition submodule is specifically used to assign, based on a preset template engine, each attribute information belonging to the same row in the first data to be filled in the blank row to the corresponding variables in the specified character area in the third document, so as to obtain the fifth document in XML format.

[0033] Optionally, the fourth document acquisition submodule is specifically used to modify the document format of the sixth document into Excel format to obtain a fourth document.

[0034] Optionally, the first document acquisition module is specifically used to acquire a seventh document in XML format obtained by format conversion of the second document;

[0035] The seventh document is formatted to obtain a first document.

[0036] An embodiment of the present invention further provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0037] Memory, used to store computer programs;

[0038] The processor is used to implement any of the above-mentioned document generation methods when executing the program stored in the memory.

[0039] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned document generation methods is implemented.

[0040] An embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the document generation methods described above.

[0041] Beneficial effects of the embodiments of the present invention:

[0042] The document generation method provided by the embodiment of the present invention can obtain a first document in XML format; wherein the first document is: obtained based on format conversion of a second document in Excel format containing blank rows to be filled; a loop expression is recorded on the upper side of the blank rows in the second document, and an end symbol is recorded on the lower side; in the first document, the previous row of the specified character area is replaced with the loop expression in the previous row, and the next row of the specified character area is replaced with the end symbol in the next row, to obtain a third document; wherein the specified character area represents the blank rows to be filled; based on a preset template engine, the third document and the first data to be filled into the blank rows are combined to obtain a final fourth document; wherein the table contained in the fourth document is filled with the first data.

[0043] Based on the above processing, the previous row of the designated character area is replaced by the loop expression in the previous row, and the next row is replaced by the terminator in the next row, so that the first data can be looped and filled into multiple blank rows based on the loop expression, and then a fourth document containing a table filled with the first data can be obtained. Compared with the prior art in which information is manually input, the method of the embodiment of the present invention automatically loops and assigns values ​​to blank rows by an electronic device, which can improve the efficiency of generating Excel documents and reduce labor costs.

[0044] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0046] Figure 1 A flowchart of a document generation method provided by an embodiment of the present invention;

[0047] Figure 2 A schematic diagram of displaying a second document provided by an embodiment of the present invention;

[0048] Figure 3 A flowchart of another document generation method provided by an embodiment of the present invention;

[0049] Figure 4 A flowchart of another document generation method provided by an embodiment of the present invention;

[0050] Figure 5 Based on Figure 2 A schematic diagram of displaying a fourth document obtained from the second document shown;

[0051] Figure 6 A structural diagram of a document generation device provided by an embodiment of the present invention;

[0052] Figure 7 A structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field based on the present invention belong to the scope of protection of the present invention.

[0054] In the related art, manually inputting the attribute information of each object into a table of an Excel document requires a large labor cost and results in a low efficiency in generating the Excel document.

[0055] In order to solve the above problems, an embodiment of the present invention provides a document generation method, which can be applied to an electronic device. The electronic device fills a table in a document in Excel format based on data provided by a user (the first data in the embodiment of the present invention, i.e., data that needs to be filled into the Excel document) to obtain the final document.

[0056] See also Figure 1, Figure 1 A flowchart of a document generation method provided by an embodiment of the present invention, the method may include the following steps:

[0057] S101: Acquire a first document in XML format.

[0058] The first document is obtained by formatting a second document in Excel format containing blank rows to be filled. A loop expression is recorded on the upper side of the blank row in the second document, and a terminator is recorded on the lower side.

[0059] S102: In the first document, a line before the designated character region is replaced with a loop expression in the previous line, and a line after the designated character region is replaced with a terminator in the next line, to obtain a third document.

[0060] The designated character area represents the blank line to be filled.

[0061] S103: Based on a preset template engine, the third document and the first data to be filled into the blank line are combined to obtain a final fourth document.

[0062] The table included in the fourth document is filled with the first data.

[0063] Based on the document generation method provided by the embodiment of the present invention, the previous line of the specified character area is replaced by the loop expression in the previous line, and the next line is replaced by the terminator in the next line, so that the first data can be looped and filled into each blank line based on the loop expression, and then, a fourth document filled with the first data in the included table can be obtained. Compared with the prior art in which information is manually input, the method of the embodiment of the present invention automatically loops and assigns values ​​to blank lines by the electronic device, which can improve the efficiency of Excel document generation and reduce labor costs.

[0064] In addition, electronic devices can automatically cycle through blank rows to assign values, thereby avoiding manual input errors.

[0065] Secondly, based on the method provided by the embodiment of the present invention, the user only needs to adjust the attributes of each space in the blank row to be filled in the second document (which can be called a template document), so as to generate a document containing different tables without editing the corresponding XML format document, thereby improving the maintainability of the template document.

[0066] With respect to step S101, the attributes of each blank space in the blank line of the second document can be set by the user based on the user's needs. Figure 2 , Figure 2 A schematic diagram of displaying a second document provided by an embodiment of the present invention.

[0067] When users need to collect statistics on work status, they can set Figure 2 The document is in Excel format as shown. That is, for each task, it is necessary to count the task's serial number, work content, planned start time, planned completion time, completion percentage, unfinished description, and person in charge.

[0068] The blank row may record the attribute identifier of each column attribute. Figure 2 In the example, $!emp.id indicates the attribute identifier of the sequence number column, $!emp.content indicates the attribute identifier of the work content column, $!emp.beginTime indicates the attribute identifier of the planned start time column, $!emp.endTime indicates the attribute identifier of the planned completion time column, $!emp.P indicates the attribute identifier of the completion percentage column, $!emp.note indicates the attribute identifier of the unfinished notes column, and $!emp.people indicates the attribute identifier of the person in charge column.

[0069] For example, a user can create an Excel document on a computer and enter Figure 2 The content shown, wherein #foreach($item in$emps) represents a loop expression, and #end represents an end character, obtains a second document. Then, the user can save the second document in XML format, and the electronic device can obtain the first document based on the document in XML format.

[0070] In one embodiment, the electronic device may directly determine the document in XML format as the first document.

[0071] In another embodiment, the above step S101 may include the following steps:

[0072] A seventh document in XML format is obtained by formatting the second document; and the seventh document is formatted to obtain the first document.

[0073] In an embodiment of the present invention, after the user saves the second document in XML format and obtains a document in XML format (i.e., the seventh document), the electronic device can obtain the seventh document and format the seventh document to obtain the first document. Formatting the seventh document includes: adding line breaks to the seventh document and adjusting the indentation of lines in the seventh document to improve the readability of the first document.

[0074] For step S102, in one implementation, since a loop expression is recorded above the blank line in the second document and an end symbol is recorded below it, when parsing the first document, the electronic device can determine the data lines in the first document that contain the loop expression (which can be called the first data lines). The area below the first data lines is the specified character area, that is, the character area representing the blank line. At the same time, the electronic device can determine the data lines in the first document that contain the end symbol (which can be called the second data lines). The area above the second data lines is the specified character area, that is, the character area representing the blank line.

[0075] For example, the first data lines in the second document can be determined based on the regular expression <Row.*?#foreach.*?, and the second data lines in the second document can be determined based on the regular expression <Row.*?#end.*?.

[0076] Furthermore, the electronic device can replace the first data lines with the loop expressions therein and replace the second data lines with the end symbols therein to obtain a third document.

[0077] The loop expression represents an expression for performing loop processing. Replacing the line before the specified character area with the loop expression therein and replacing the line after it with the end symbol therein can achieve loop processing of the content represented by the specified character area.

[0078] For step S103, the template engine in the embodiments of the present invention can be a Velocity template engine, or it can also be a Freemarker template engine, but it is not limited thereto.

[0079] The first data that the user needs to fill can be recorded in a specified database, or it can also be recorded in a specified document. The first data can be marked with corresponding attribute identifiers, that is, the electronic device can determine the attributes of each data in the first data.

[0080] In one embodiment, referring to Figure 3 , on the basis of Figure 1 , the above step S103 can include the following steps:

[0081] S1031: Based on a preset template engine, combine the third document and the first data to be filled into the blank lines to obtain a fifth document in XML format.

[0082] S1032: Count the number of data lines recorded in the fifth document as the target value.

[0083] S1033: Modify the variable representing the number of data lines in the fifth document to the target value to obtain a sixth document.

[0084] S1034: Based on the sixth document, obtain a fourth document in Excel format.

[0085] The table included in the fifth document is filled with the first data.

[0086] The first data may include multiple lines of data, each line of data including multiple different attribute information. For example, if the content of the second document is Figure 2 As shown, each row of data in the first data represents information about a task, including the task's serial number, task content, planned start time, planned completion time, completion percentage, unfinished description, and person in charge. That is, the first data may contain information about multiple tasks.

[0087] In an embodiment of the present invention, the electronic device can combine the third document and the first data based on the template engine, that is, fill the first data into the blank row to obtain the fifth document in XML format. Since multiple blank rows can be filled in a loop, and Excel has requirements for row counting, that is, the number of rows containing data needs to be recorded in the Excel document. Therefore, after the filling is completed, the number of data rows recorded in the fifth document (i.e., the target value) can be counted, and the variable representing the number of data rows in the fifth document can be modified to the target value, thereby avoiding errors when opening the document.

[0088] For example, in the fifth document, the value of the variable "ExpandedRowCount" indicating the number of data rows may be modified to a target value.

[0089] Although the sixth document is in XML format, it can still be directly opened based on Office application and displayed in the form of Excel document. For example, based on Office 2007 and higher versions, the document in XML format can be directly opened in the form of Excel document.

[0090] In one embodiment, the above step S1034 may include: modifying the document format of the sixth document to Excel format to obtain a fourth document.

[0091] To facilitate the user to manage documents, the electronic device may also modify the suffix of the sixth document to the suffix of an Excel format document (eg, .xls) to obtain a document in Excel format (ie, the fourth document in the embodiment of the present invention).

[0092] In one embodiment, see Figure 4 ,exist Figure 3 On the basis of, the above step S1031 may include the following steps:

[0093] S10311: Based on a preset template engine, for each attribute information belonging to the same row in the first data to be filled into the blank row, assign values ​​to corresponding variables in the specified character area in the third document in sequence to obtain a fifth document in XML format.

[0094] In the embodiment of the present invention, based on the template engine, for each attribute information belonging to the same row in the first data, that is, for multiple attribute information of the same object to be filled, values ​​can be assigned to corresponding variables in the designated character area in sequence. In other words, the electronic device can assign values ​​to the variables in the designated character area according to the first data, and thus fill the corresponding first data in the blank row.

[0095] After completing the assignment of each variable in the specified character area, you can get a data row filled with the attribute information of a corresponding object. Furthermore, after completing multiple loop assignments based on the loop expression, you can fill multiple blank rows with the attribute information of multiple objects (i.e., the first data), that is, you can get a data row containing the attribute information of multiple objects.

[0096] See also Figure 5 , Figure 5 Based on Figure 2 A schematic diagram of displaying a fourth document obtained from the second document shown.

[0097] Based on the same inventive concept, the embodiment of the present invention further provides a document generation device, see Figure 6 , Figure 6 A structural diagram of a document generation device provided in an embodiment of the present invention, the device comprising:

[0098] The first document acquisition module 601 is used to acquire a first document in an extensible markup language XML format; wherein the first document is obtained by converting a second document in an Excel format containing blank rows to be filled; a loop expression is recorded on the upper side of the blank rows in the second document, and a terminator is recorded on the lower side;

[0099] The third document acquisition module 602 is used to replace the previous line of the designated character area with the loop expression in the previous line, and replace the next line of the designated character area with the terminator in the next line, in the first document, to obtain a third document; wherein the designated character area represents the blank line to be filled;

[0100] The fourth document acquisition module 603 is used to combine the third document and the first data to be filled into the blank row based on a preset template engine to obtain a final fourth document; wherein the table contained in the fourth document is filled with the first data.

[0101] Optionally, the template engine is a Velocity template engine or a Freemarker template engine.

[0102] Optionally, the fourth document acquisition module 603 includes:

[0103] A fifth document acquisition submodule, configured to combine the third document and the first data to be filled into the blank row based on a preset template engine to obtain a fifth document in XML format; the table included in the fifth document is filled with the first data;

[0104] A target value acquisition submodule, used for counting the number of data rows recorded in the fifth document as a target value;

[0105] A modification submodule, used for modifying the variable representing the number of data rows in the fifth document to the target value, so as to obtain a sixth document;

[0106] The fourth document acquisition submodule is used to obtain a fourth document in Excel format based on the sixth document.

[0107] Optionally, the fifth document acquisition submodule is specifically used to assign, based on a preset template engine, each attribute information belonging to the same row in the first data to be filled in the blank row to the corresponding variables in the specified character area in the third document, so as to obtain the fifth document in XML format.

[0108] Optionally, the fourth document acquisition submodule is specifically used to modify the document format of the sixth document into Excel format to obtain a fourth document.

[0109] Optionally, the first document acquisition module 601 is specifically configured to acquire a seventh document in XML format obtained by format conversion of the second document;

[0110] The seventh document is formatted to obtain a first document.

[0111] Based on the document generation device provided by the embodiment of the present invention, the previous line of the designated character area is replaced by the loop expression in the previous line, and the next line is replaced by the terminator in the next line, so that the first data can be looped and filled into each blank line based on the loop expression, and then the fourth document containing the table filled with the first data can be obtained. Compared with the prior art in which information is input manually, the method of the embodiment of the present invention automatically loops and assigns values ​​to blank lines by the electronic device, which can improve the efficiency of Excel document generation and reduce labor costs.

[0112] The embodiment of the present invention further provides an electronic device, such as Figure 7As shown, it includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704.

[0113] Memory 703, used for storing computer programs;

[0114] The processor 701 is used to execute the program stored in the memory 703 to implement the following steps:

[0115] Acquire a first document in an extensible markup language XML format; wherein the first document is obtained by formatting a second document in an Excel format that includes blank rows to be filled; a loop expression is recorded on the upper side of the blank row in the second document, and a terminator is recorded on the lower side;

[0116] In the first document, a line before the designated character region is replaced with a loop expression in the previous line, and a line after the designated character region is replaced with a terminator in the latter line, to obtain a third document; wherein the designated character region represents the blank line to be filled;

[0117] Based on a preset template engine, the third document and the first data to be filled into the blank row are combined to obtain a final fourth document; wherein the table included in the fourth document is filled with the first data.

[0118] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0119] The communication interface is used for communication between the above electronic device and other devices.

[0120] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0121] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0122] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above document generation methods are implemented.

[0123] In another embodiment of the present invention, a computer program product including instructions is provided, which, when executed on a computer, enables the computer to execute any document generation method in the above embodiments.

[0124] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0125] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0126] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0127] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A document generation method, characterized in that: The method comprises: Acquire a first document in an extensible markup language XML format; wherein the first document is obtained by format conversion of a second document in an Excel format containing blank rows to be filled; a loop expression is recorded on the upper side of the blank rows in the second document, and a terminator is recorded on the lower side; and an attribute identifier of each column attribute is recorded in the blank rows to be filled; In the first document, a line before the designated character region is replaced with a loop expression in the previous line, and a line after the designated character region is replaced with a terminator in the latter line, to obtain a third document; wherein the designated character region represents the blank line to be filled; Based on a preset template engine, the third document and the first data to be filled into the blank row are combined to obtain a final fourth document; wherein the table included in the fourth document is filled with the first data.

2. The method according to claim 1, characterized in that The template engine is a Velocity template engine or a Freemarker template engine.

3. The method according to claim 1, characterized in that The preset template engine combines the third document and the first data to be filled into the blank line to obtain a final fourth document, including: Based on a preset template engine, the third document and the first data to be filled into the blank row are combined to obtain a fifth document in XML format; the table included in the fifth document is filled with the first data; Counting the number of data rows recorded in the fifth document as a target value; Modify the variable representing the number of data rows in the fifth document to the target value to obtain a sixth document; Based on the sixth document, a fourth document in Excel format is obtained.

4. The method according to claim 3, characterized in that The preset template engine combines the third document and the first data to be filled into the blank line to obtain a fifth document in XML format, including: Based on a preset template engine, for each attribute information belonging to the same row in the first data to be filled into the blank row, values ​​are sequentially assigned to corresponding variables in the designated character area in the third document to obtain a fifth document in XML format.

5. The method according to claim 3, characterized in that: The method of obtaining a fourth document in Excel format based on the sixth document includes: The document format of the sixth document is modified into Excel format to obtain a fourth document.

6. The method according to claim 1, characterized in that The step of obtaining the first document in XML format includes: Acquire a seventh document in XML format obtained by format conversion of the second document; The seventh document is formatted to obtain a first document.

7. A document generation device, characterized in that: The device comprises: A first document acquisition module is used to acquire a first document in an extensible markup language XML format; wherein the first document is obtained by formatting a second document in an Excel format containing blank rows to be filled; a loop expression is recorded on the upper side of the blank rows in the second document, and a terminator is recorded on the lower side; and an attribute identifier of each column attribute is recorded in the blank rows to be filled; A third document acquisition module is used to replace the previous line of the designated character area with the loop expression in the previous line, and replace the next line of the designated character area with the terminator in the next line, in the first document, to obtain a third document; wherein the designated character area represents the blank line to be filled; The fourth document acquisition module is used to combine the third document and the first data to be filled into the blank row based on a preset template engine to obtain a final fourth document; wherein the table contained in the fourth document is filled with the first data.

8. The device according to claim 7, characterized in that The template engine is a Velocity template engine or a Freemarker template engine.

9. The device according to claim 7, characterized in that The fourth document acquisition module includes: A fifth document acquisition submodule, configured to combine the third document and the first data to be filled into the blank row based on a preset template engine to obtain a fifth document in XML format; the table included in the fifth document is filled with the first data; A target value acquisition submodule, used for counting the number of data rows recorded in the fifth document as a target value; a modification submodule, configured to modify the variable representing the number of data rows in the fifth document to the target value, so as to obtain a sixth document; The fourth document acquisition submodule is used to obtain a fourth document in Excel format based on the sixth document.

10. The device according to claim 9, characterized in that The fifth document acquisition submodule is specifically used to assign values ​​of various attribute information belonging to the same row in the first data to be filled in the blank row to corresponding variables in the specified character area in the third document based on a preset template engine, so as to obtain a fifth document in XML format.

11. The device according to claim 9, characterized in that The fourth document acquisition submodule is specifically used to modify the document format of the sixth document into Excel format to obtain a fourth document.

12. The device according to claim 7, characterized in that The first document acquisition module is specifically used to acquire a seventh document in XML format obtained by format conversion of the second document; The seventh document is formatted to obtain a first document.

13. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 6 when executing a program stored in a memory.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 6 are implemented.