Word document generation method, device, equipment, storage medium and product

By splitting the word file in docx format into multiple single files and merging and compressing, the memory overflow problem when generating large-volume word files is solved, and stable and efficient document generation is achieved.

CN119248728BActive Publication Date: 2025-04-22SECZONE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411775960.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-04-22
Estimated Expiration
2044-12-05

AI Technical Summary

Technical Problem

In the prior art, when generating large-volume docx format word files, there is a linear increase in memory usage problem, which can easily lead to memory overflow.

Method used

By splitting the word file in docx format into multiple single files, and saving the word document data in memory into each single file according to the upper limit of the data volume of each batch of data, and finally combining and compressing multiple single files to generate the final word document in docx format.

Benefits of technology

It effectively avoids the problem of memory overflow, controls the balance of memory usage and generation time, and realizes the stable generation of large-scale word documents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248728B_ABST
    Figure CN119248728B_ABST
Patent Text Reader

Abstract

The present application discloses a word document generation method, device, equipment, storage medium and product, and relates to the field of document processing technology. The method includes: generating multiple single files corresponding to a word file in docx format; saving the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data; merging and compressing the multiple single files to generate a final word document in docx format. The present application generates multiple separate files by splitting a word file, and then saves the word document data in the memory into each of the single files in batches according to the upper limit of the data volume of each batch of data, so that the memory occupied does not exceed the memory range. The data generator only needs to control the size of each batch of data to control the balance between memory usage and generation time. Then all single files are merged and compressed to generate the final document in a streaming manner.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of document processing technology, and in particular to a word document generation method, device, equipment, storage medium and product. Background Art

[0002] The existing generated word files in docx format usually use the poi component library. When generating word files, the poi component library needs to build all document objects in memory and then output the document objects to the file. In scenarios where large files such as reports need to be generated, there is a problem of linearly growing memory usage. Because of this problem, as long as a large word document is generated, it is very easy to cause memory overflow, causing program abnormalities or even operating system abnormalities. And when using the poi component library to read a word file, it is also necessary to convert the entire file into a document object and store it in memory, which can easily lead to memory overflow problems. Summary of the invention

[0003] The main purpose of this application is to provide a word document generation method, device, equipment, storage medium and product, aiming to solve the technical problem of linearly growing memory usage when generating large-volume word documents.

[0004] To achieve the above purpose, the present application proposes a method for generating a word document, the method comprising:

[0005] Generate multiple single files corresponding to the word file in docx format;

[0006] The word document data in the memory is saved into each of the single files according to the upper limit of the data volume of each batch of data;

[0007] Merge and compress the multiple single files to generate a final word document in docx format.

[0008] In one embodiment, before the step of saving the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data, the method further includes:

[0009] Get the current available memory;

[0010] Get the size of each piece of data in each batch of data in turn;

[0011] An upper limit value of the data amount of each batch of data is determined according to the currently available memory and the size of each piece of data.

[0012] In one embodiment, the plurality of single files include a header file, an endnote file, a footer file, and a document file;

[0013] The step of merging and compressing the multiple single files to generate a final word document in docx format includes:

[0014] Merging the generated endnote file, the footer file and the header file into the document file;

[0015] Add closing tags in XML format to the head and tail of the document file to obtain a complete document file;

[0016] The complete document file is compressed to obtain a final word document in docx format.

[0017] In one embodiment, the step of saving the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data includes:

[0018] When the single file is the header file, determining whether the header content in the word document data in the memory is text;

[0019] If the header content is text, then generate the header text style according to the header content and attribute modification tags according to the data volume upper limit of each batch of data;

[0020] The text content of the generated header is set according to the header content and the text content tag, and the text style and text content of the generated header are added to the header file.

[0021] In one embodiment, when the single file is the header file, after the step of determining whether the header content in the word document data in the memory is text, the method further includes:

[0022] If the header content is a picture, the header picture information is generated according to the header content and the drawing object label according to the data amount upper limit of each batch of data, and the generated header picture information is added to the header file.

[0023] In one embodiment, the step of saving the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data includes:

[0024] When the single file is the footer file, footer information is generated according to the footer content and footer tags in the word document data in the memory according to the upper limit of the data volume of each batch of data, and the generated footer information is added to the footer file;

[0025] When the single file is the footnote file, footnote information is generated according to the footnote content and footnote tags in the word document data in the memory according to the data amount upper limit of each batch of data, and the generated footnote information is added to the footnote file.

[0026] In addition, to achieve the above purpose, the present application also proposes a word document generation device, the word document generation device comprising:

[0027] Single file generation module, used to generate multiple single files corresponding to word files in docx format;

[0028] A document data saving module, used to save the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data;

[0029] The word document generation module is used to merge and compress the multiple single files to generate a final word document in docx format.

[0030] In addition, to achieve the above-mentioned purpose, the present application also proposes a word document generation device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the word document generation method described above.

[0031] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the word document generation method described above are implemented.

[0032] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the word document generation method described above are implemented.

[0033] The present application provides a word document generation method, by generating multiple single files corresponding to a word file in docx format; saving the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data; merging and compressing the multiple single files to generate a final word document in docx format. The present application generates multiple separate files by splitting a word file in docx format, and then saves the word document data in the memory into each of the single files in batches according to the upper limit of the data volume of each batch of data, so that the memory occupied each time a document is generated does not exceed the existing memory range, and the data generator only needs to control the size of each batch of data to control the balance between memory usage and generation time. Then all the single files are merged and compressed, and the final large-volume word document in docx format is generated in a streaming manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0035] In order to more clearly illustrate the embodiments of the present application 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0036] Figure 1 A flowchart of the first embodiment of the word document generation method of the present application is provided;

[0037] Figure 2 This is a schematic diagram of the word file content in the word document generation method of this application;

[0038] Figure 3 This is a schematic diagram of the word folder content in the word document generation method of this application;

[0039] Figure 4 A flowchart of the second embodiment of the word document generation method of the present application is provided;

[0040] Figure 5 This is a schematic diagram of the overall process of the word document generation method for this application;

[0041] Figure 6 This is a schematic diagram of the module structure of the word document generation device according to an embodiment of the present application;

[0042] Figure 7 This is a schematic diagram of the device structure of the hardware operating environment involved in the word document generation method in the embodiment of the present application.

[0043] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0044] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0045] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0046] The main solution of the embodiment of the present application is: generate multiple single files corresponding to the word file in docx format; save the word document data in the memory into each of the single files according to the data amount upper limit of each batch of data; merge and compress the multiple single files to generate the final word document in docx format.

[0047] Because the word files in docx format generated by the prior art usually use the poi component library. When generating a word file, the poi component library needs to build all document objects in the memory, and then output the document objects to the file. In scenarios where large files such as reports need to be generated, there is a problem of linearly growing memory usage. Because of this problem, as long as a large word document is generated, it is very easy to cause memory overflow, causing program abnormalities or even operating system abnormalities. And when using the poi component library to read a word file, it is also necessary to convert the entire file into a document object and store it in memory, which can easily lead to memory overflow problems.

[0048] The present application provides a solution, by generating multiple single files corresponding to a word file in docx format; saving the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data; merging and compressing the multiple single files to generate the final word document in docx format. The present application generates multiple separate files by splitting a word file in docx format, and then saves the word document data in the memory into each of the single files in batches according to the upper limit of the data volume of each batch of data, so that the memory occupied each time a document is generated does not exceed the existing memory range. The data generator only needs to control the size of each batch of data to control the balance between memory usage and generation time. Then all the single files are merged and compressed, and the final large-volume word document in docx format is generated in a streaming manner.

[0049] It should be noted that the execution subject of the method of this embodiment can be a computing service device with word document generation, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc.; it can also be a word document generation device with the same or similar functions. This embodiment and the following embodiments will be described by taking the word document generation device as an example.

[0050] Based on this, the present application embodiment provides a word document generation method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the word document generation method of this application.

[0051] In this embodiment, the word document generation method includes steps S10 to S30:

[0052] Step S10, generating multiple single files corresponding to the word file in docx format.

[0053] It should be noted that the target word file in docx format is essentially a compressed file, which contains folders and files such as _rels, customXml, docProps, word and [Content_Types].xml. The specific contents of the word file can be found in Figure 2 When generating a word file in docx format, the main thing generated is Figure 2 The contents of the word folder in .

[0054] It is understandable that in this embodiment, the process of generating a large word document is divided into multiple processes, which are generated one by one to avoid occupying a large amount of memory at one time when generating a large word document, causing abnormal interruption due to memory overflow. Therefore, in this embodiment, multiple single files corresponding to the word file in docx format are first generated.

[0055] Step S20, saving the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data.

[0056] It is worth noting that the data generator only needs to control the size of each batch of data to control the balance between memory usage and generation time. The word document data in the memory is saved into each of the single files according to the pre-calculated upper limit of the data volume corresponding to each batch of data. When the memory is insufficient, multiple batches of output can generate files when the program has little available memory. When the memory is sufficient, fewer output batches can be used to achieve less generation time.

[0057] In a feasible implementation manner, before step S20, steps S11 to S13 may also be included:

[0058] Step S11, obtaining the currently available memory.

[0059] Step S12, sequentially obtaining the size of each piece of data in each batch of data.

[0060] It is understandable that the upper limit of the amount of data for each batch can be calculated based on the available memory. First, the current available memory of the word document generation device is obtained. Then the size of each piece of data in each batch of data is estimated, and the size of each piece of data is superimposed to obtain the total memory size occupied by each batch of data.

[0061] Step S13, determining an upper limit value of the data volume of each batch of data according to the currently available memory and the size of each piece of data.

[0062] It is understandable that the upper limit of the amount of data in each batch is determined based on the current available memory and the size of each piece of data, which can be specifically calculated according to the following formula:

[0063] dataSize = (runtime.freeMemory() * 0.6) / (1024 * 1024) / metaDataSize,

[0064] Among them, metaDataSize represents the estimated size of each piece of data, runtime.freeMemory() represents the function of obtaining the current available memory, and dataSize represents the upper limit of the amount of data in each batch.

[0065] Step S30, merging and compressing the multiple single files to generate a final word document in docx format.

[0066] It is understandable that the multiple single files generated are merged to form a word document in docx format. Since the word document is essentially a compressed file, the merged word document in docx format can also be compressed, and the obtained file in a compressed format such as zip is the final word document in docx format.

[0067] In a feasible implementation manner, the multiple single files include a header file, an endnote file, a footer file, and a document file; step S30 may include steps S301 to S303:

[0068] Step S301, merging the generated endnote file, the footer file and the header file into the document file.

[0069] It should be noted that you can refer to Figure 3 Describe the contents of the word folder. Figure 3 This is a schematic diagram of the word folder content in the word document generation method of this application. The content in the word folder includes document.xml (document file), endnotes.xml (endnote file), footer1.xml (footer file), header1.xml (header file) and other main files, which determine most of the content of the word file. In addition to the main files, other contents, such as styles.xml (font style file), use the files in the word template.

[0070] Among them, the document file document.xml is the core content file of the word document, which contains the main text content and format information of the document. This file stores all the text content, paragraphs, styles and other elements of the document in XML format. Therefore, the contents of the generated endnote files, footer files, header files and other main files can be merged into the document file document.xml.

[0071] Step S302, adding closing tags in XML format to the head and tail of the document file to obtain a complete document file.

[0072] It is understandable that after merging the contents of the generated endnote files, footer files, header files and other main files into the document file document.xml in the above steps, it is also necessary to encapsulate the document file and add a closing tag to ensure the integrity of the xml structure. The closing tag is "".

[0073] Step S303, compressing the complete document file to obtain a final word document in docx format.

[0074] It is understandable that the complete document file document.xml can finally be compressed into a compressed file in a zip format, thereby obtaining the final word document in docx format.

[0075] This embodiment provides a word document generation method, by generating multiple single files corresponding to a word file in docx format; saving the word document data in the memory into each of the single files according to the data volume upper limit of each batch of data; merging and compressing the multiple single files to generate a final word document in docx format. In this embodiment, a word file in docx format is split into multiple separate files, and then the word document data in the memory is saved in batches into each of the single files according to the data volume upper limit of each batch of data, so that the memory occupied each time a document is generated does not exceed the existing memory range, and the data generator only needs to control the size of each batch of data to control the balance between memory usage and generation time. Then all the single files are merged and compressed, and the final large-volume word document in docx format is generated in a streaming manner.

[0076] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can refer to the above introduction, and will not be repeated later. Figure 4 , step S20, the word document generation method further includes steps S201~S203:

[0077] Step S201, when the single file is the header file, determine whether the header content in the word document data in the memory is text.

[0078] It is understandable that headers, footers, endnotes and other files can be generated. Since these files are relatively small, there is no memory bottleneck when they are generated at one time. Since headers can be text or pictures, when writing document content to the single file corresponding to the header file, it is possible to first determine whether the header content in the word document data in the memory is text or picture. There are differences in the corresponding XML tags for different types.

[0079] Step S202: if the header content is text, then generate the header text style according to the header content and attribute modification tags according to the upper limit of the data volume of each batch of data.

[0080] It should be understood that if you want to generate text from left to right, you should use the attribute modification tag (w:rPr tag) to set the text style according to the upper limit of the data volume of each batch of data. The w:rPr tag is an attribute modification tag. <w:r>The subtags within the tag are mainly used to modify the Run text attributes. These attributes can include text formatting such as bold, italic, underline, font size, etc. When the w:rPr element appears in w:pPr, it only applies to the glyph (first section) paragraph. If you want to format the paragraph glyph, you need to add attributes to it.

[0081] Step S203, setting the text content of the generated header according to the header content and the text content tag, and adding the text style and text content of the generated header to the header file.

[0082] It should be noted that the w:t tag is a text content tag, which represents the actual text content. In the XML structure of a word document, all text content is contained in <w:t>Tags. If you need to keep the spaces before and after the text in a word document, you can <w:t>Use the xml:space="preserve" attribute in the tag. In this way, even if there are extra spaces before and after the text, they will be preserved by Word.

[0083] It is understandable that the text content of the generated header can be set according to the header content and text content tag (w:t tag) according to the data volume upper limit of each batch of data. Then the text style and text content of the generated header are added to the header file to generate the header file.

[0084] In a feasible implementation manner, after step S201, step S204 may also be included:

[0085] Step S204, if the header content is a picture, generate header picture information according to the header content and the drawing object label according to the data volume upper limit of each batch of data, and add the generated header picture information to the header file.

[0086] It should be noted that the w:drawing tag is a tag used in the Office Open XML (OOXML) format to describe drawing objects in a Word document. Defining drawing objects: The w:drawing tag is used to define drawing objects in a Word document, such as pictures and graphics. This tag usually contains multiple sub-elements, which describe various properties and characteristics of the drawing object, such as size, position, style, etc. When inserting pictures or graphics in a Word document, you can use the w:drawing tag to set its properties and position to achieve better document layout effects.

[0087] It is understandable that if you want to generate a picture header, use the w:drawing tag, where<pic:cNvPrid="0" name="Picture 0" descr="" / > It points to the image in the media folder under the same directory. The id is the image id. id="0" means it points to the image1.png file.

[0088] In a feasible implementation manner, step S20 may further include steps S205-S206:

[0089] Step S205, when the single file is the footer file, generate footer information according to the footer content and footer tags in the word document data in the memory according to the data amount upper limit of each batch of data, and add the generated footer information to the footer file.

[0090] It should be noted that <w:ftr>The tag is used to define the footer content in a Word document. It contains all the text, pictures and other elements of the footer, and allows users to customize the format and style of the footer. In a Word document, the footer usually contains information such as page numbers, copyright information, company name, etc. By using <w:ftr>Tags, users can easily add this information at the bottom of each page of the document, thus achieving professional formatting and better readability of the document.

[0091] It is understandable that when you need to generate a footer file, you can use <w:ftr>The tag generates footer information according to the footer content in the word document data in the memory according to the upper limit of the data volume of each batch of data, and adds the generated footer information to the footer file.

[0092] Step S206, when the single file is the footnote file, footnote information is generated according to the footnote content and footnote tags in the word document data in the memory according to the upper limit of the data volume of each batch of data, and the generated footnote information is added to the footnote file.

[0093] It should be noted that <w:endnotes>The tag is used to define the content of endnotes in a Word document. It contains a collection of all endnotes, each of which can contain elements such as text and images. In a Word document, endnotes are usually used to provide additional comments or reference information. By using <w:endnotes>Tags, users can add these comments at the end of the document to help readers better understand the document content.

[0094] It should be understood that when you need to generate a footnote file, you can <w:endnotes>The tag generates footnote information according to the footnote content in the word document data in the memory according to the upper limit of the data amount of each batch of data, and adds the generated footnote information to the footnote file.

[0095] In this embodiment, when a single file is a header file, a footer file or an endnote file, the corresponding header, footer or endnote information is generated according to the corresponding label. The text style of the header is generated according to the header content and the attribute modification label according to the upper limit of the data volume of each batch of data, the text content of the header is generated according to the header content and the text content label setting, the picture information of the header is generated according to the header content and the drawing object label, the footer information is generated according to the footer content and the footer label, and the endnote information is generated according to the endnote content and the endnote label. And the generated information is added to the corresponding files respectively, so that multiple single files can be generated one by one, instead of generating a whole large-volume word document at one time, avoiding memory overflow.

[0096] For example, in order to help understand the implementation process of the word document generation method obtained by combining this embodiment with the above-mentioned embodiment 1, please refer to Figure 5 , Figure 5 This is a schematic diagram of the overall process of the word document generation method of this application, specifically:

[0097] This application splits a word file in docx format into multiple files for generation, such as header files, footer files, endnote files, and document files. The data generator needs to control the size of each batch of data to control the balance between memory usage and generation time. Control the data size in the program and call the document content generation method in batches. When the document data reaches the upper limit of the data volume, add content to the document. The document content needs to be output to document.xml. Because of the sharding, multiple small xmls are generated each time and then merged into one document.xml. Here, streaming merge can be performed in plain text, so there is no memory limit. After all the files are merged, add a closing tag to the xml file to ensure the integrity of the xml structure.

[0098] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the word document generation method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0099] This application also provides a word document generation device, please refer to Figure 6 , the word document generating device comprises:

[0100] A single file generation module 10 is used to generate multiple single files corresponding to the word file in docx format;

[0101] The document data saving module 20 is used to save the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data;

[0102] The word document generation module 30 is used to merge and compress the multiple single files to generate a final word document in docx format.

[0103] The word document generation device provided by the present application adopts the word document generation method in the above embodiment to solve the technical problem. Compared with the prior art, the beneficial effects of the word document generation device provided by the present application are the same as the beneficial effects of the word document generation method provided by the above embodiment, and other technical features in the word document generation device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0104] The present application provides a word document generation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the word document generation method in the above-mentioned embodiment one.

[0105] Reference below Figure 7 , which shows a schematic diagram of the structure of a word document generation device suitable for implementing the embodiment of the present application. The word document generation device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The word document generation device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0106] like Figure 7 As shown, the word document generation device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the word document generation device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the word document generation device to communicate wirelessly or wired with other devices to exchange data. Although the word document generation device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided alternatively.

[0107] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0108] The word document generation device provided by the present application adopts the word document generation method in the above embodiment, which can solve the technical problem of word document generation. Compared with the prior art, the beneficial effects of the word document generation device provided by the present application are the same as the beneficial effects of the word document generation method provided by the above embodiment, and other technical features in the word document generation device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0109] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0110] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0111] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the word document generation method in the above-mentioned embodiment.

[0112] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.

[0113] The above-mentioned computer-readable storage medium may be included in the word document generating device; or it may exist independently without being assembled into the word document generating device.

[0114] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by a word document generating device, the word document generating device: generates multiple single files corresponding to the word files in docx format; saves the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data; merges and compresses multiple single files to generate a final word document in docx format.

[0115] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0116] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0117] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0118] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned word document generation method, and can solve the technical problem. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the word document generation method provided in the above-mentioned embodiment, and will not be repeated here.

[0119] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned word document generation method when executed by a processor.

[0120] The computer program product provided by the present application can solve the technical problem. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the word document generation method provided by the above embodiment, which will not be repeated here.

[0121] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.< / w:endnotes> < / w:endnotes> < / w:endnotes> < / w:ftr> < / w:ftr> < / w:ftr> < / w:t> < / w:t> < / w:r>

Claims

1. A method for generating a word document, characterized in that: The method includes: Generate multiple single files corresponding to the word file in docx format, wherein the multiple single files include a header file, an endnote file, a footer file and a document file; The word document data in the memory is saved into each of the single files according to the upper limit of the data volume of each batch of data; Merge and compress the multiple single files to generate a final word document in docx format; Before the step of saving the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data, the method further includes: Get the current available memory; Get the size of each piece of data in each batch of data in turn; Determine an upper limit value of the data volume of each batch of data according to the currently available memory and the size of each piece of data; The step of merging and compressing the multiple single files to generate a final word document in docx format includes: Merging the generated endnote file, the footer file and the header file into the document file; Add closing tags in XML format to the head and tail of the document file to obtain a complete document file; Compress the complete document file to obtain a final word document in docx format; The step of saving the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data includes: When the single file is the header file, determining whether the header content in the word document data in the memory is text; If the header content is text, then generate the header text style according to the header content and attribute modification tags according to the data volume upper limit of each batch of data; Setting the text content of the generated header according to the header content and the text content tag, and adding the text style and text content of the generated header to the header file; If the header content is a picture, the header picture information is generated according to the header content and the drawing object label according to the data volume upper limit of each batch of data, and the generated header picture information is added to the header file; When the single file is the footer file, footer information is generated according to the footer content and footer tags in the word document data in the memory according to the upper limit of the data volume of each batch of data, and the generated footer information is added to the footer file; When the single file is the footnote file, footnote information is generated according to the footnote content and footnote tags in the word document data in the memory according to the data amount upper limit of each batch of data, and the generated footnote information is added to the footnote file.

2. A word document generation device, characterized in that: The word document generating device comprises: A single file generation module, used to generate multiple single files corresponding to a word file in docx format, wherein the multiple single files include a header file, an endnote file, a footer file and a document file; A document data saving module, used to save the word document data in the memory into each of the single files according to the upper limit of the data volume of each batch of data; A word document generation module, used to merge and compress multiple single files to generate a final word document in docx format; The document data storage module is further used to obtain the current available memory, sequentially obtain the size of each piece of data in each batch of data, and determine the upper limit of the data volume of each batch of data according to the current available memory and the size of each piece of data; The word document generation module is further used to merge the generated endnote file, the footer file and the header file into the document file, add closing tags in XML format to the head and tail of the document file to obtain a complete document file, compress the complete document file, and obtain a final word document in docx format; The document data saving module is further used to determine whether the header content in the word document data in the memory is text when the single file is the header file; if the header content is text, generate the text style of the header according to the header content and the attribute modification tag according to the data volume upper limit of each batch of data; set the text content of the generated header according to the header content and the text content tag, and add the text style and text content of the generated header to the header file; The document data saving module is further used for generating header picture information according to the header content and the drawing object label according to the data amount upper limit of each batch of data if the header content is a picture, and adding the generated header picture information to the header file; The document data saving module is also used to generate footer information according to the footer content and footer tags in the word document data in the memory according to the data amount upper limit of each batch of data when the single file is the footer file, and add the generated footer information to the footer file; when the single file is the footnote file, generate footnote information according to the footnote content and footnote tags in the word document data in the memory according to the data amount upper limit of each batch of data, and add the generated footnote information to the footnote file.

3. A word document generation device, characterized in that: The device comprises: a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the word document generation method as claimed in claim 1.

4. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the word document generation method according to claim 1 are implemented.

5. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the word document generation method as claimed in claim 1 are implemented.

Citation Information

Patent Citations

  • Method and device for generating performance report

    CN102215126A

  • Electronic spreadsheet generating method and device

    CN104881275A