Template engine-based file management method and device, medium and program product
By configuring the version conversion rules and template engines, the office file version is automatically converted, which solves the problem that the template engine cannot output different versions of files in the existing technology, and realizes efficient file management and online editing functions, improving the efficiency and compatibility of office file management.
Patent Information
- Application Number
- CN202510321262.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-07-08
AI Technical Summary
The existing template engine cannot output different versions of office files, and requires manual tedious format conversion, resulting in low efficiency in office file management.
By configuring the version conversion rules and template engine, temporary office files are generated, and version conversion service is called when versions do not match, the files are automatically converted to the required version, providing online editing functions and caching mechanisms, and improving file management compatibility and efficiency.
It realizes the generation of different versions of office files according to user needs, improves the efficiency and compatibility of office file management, meets online editing needs, reduces manual operations, and improves reliability and efficiency.
Smart Images

Figure CN120278660A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of document management. Specifically, it relates to a document management method, device, medium, and program product based on a template engine. Background Art
[0002] A template engine can separate the user interface from business data. Through the template engine, data can be filled into a predefined template to generate a document in a specific format.
[0003] However, the existing template engines can only output documents corresponding to the predefined template version and cannot output different versions of office documents based on the same template file. Manual and cumbersome format conversion is required, resulting in low efficiency in office document management. Summary of the Invention
[0004] The purpose of the embodiments of this application is to provide a document management method, device, medium, and program product based on a template engine to improve the efficiency of office document management.
[0005] In a first aspect, the embodiments of this application provide a document management method based on a template engine, including:
[0006] Obtain a to-be-processed office document and a to-be-processed content attachment, and generate a template file based on the to-be-processed office document;
[0007] Use a preset template engine to generate a temporary office document based on the template file and the to-be-processed content attachment;
[0008] When it is determined that the version of the temporary office document matches the preset output requirement information, use the temporary office document as the final office document and output it;
[0009] When it is determined that the version of the temporary office document does not match the preset output requirement information, call a preset version conversion service to perform version conversion on the temporary office document, and use the temporarily office document after version conversion as the final office document and output it.
[0010] In the embodiments of this application, by configuring version conversion rules, after the system generates a temporary office document based on the template engine, different versions of office documents can be generated according to user needs, effectively improving the efficiency of office document management.
[0011] In some possible embodiments, generating the template file based on the to-be-processed office document includes:
[0012] When it is determined that the version of the to-be-processed office document is inconsistent with the recognition version of the template engine, call the version conversion service to perform version conversion on the to-be-processed office document;
[0013] Generate a template file based on the office file to be processed after version conversion.
[0014] In the embodiments of the present application, by configuring version conversion rules, input files of different versions can be converted into versions recognizable by the template engine, thereby effectively improving the compatibility of office file management.
[0015] In some possible embodiments, the file management method based on the template engine further includes:
[0016] In response to a user's online editing request for the final office file, determine whether the version of the final office file meets the preset version requirements;
[0017] If so, convert the final office file into an HTML file and provide an online editing page based on the HTML file;
[0018] If not, call the version conversion service to perform version conversion on the temporary office file, so as to convert the final office file after version conversion into an HTML file and provide an online editing page based on the HTML file.
[0019] In the embodiments of the present application, by providing an online file editing function and calling the version conversion service to perform version conversion when the generated office file does not meet the version requirements, the online editing requirements of users for files of different versions are met, and the efficiency of office file management is further improved.
[0020] In some possible embodiments, after generating the temporary office file based on the template file and the attachment of the content to be processed using the preset template engine, it further includes:
[0021] Cache the temporary office file when it is determined that the version of the temporary office file meets the preset version requirements;
[0022] In response to a user's online editing request for the final office file, when it is determined that the version of the final office file does not meet the preset version requirements, convert it into an HTML file based on the cached temporary office file and provide an online editing page corresponding to the final office file based on the HTML file.
[0023] In the embodiments of the present application, by caching the temporary office file generated by the template engine and providing an online editing page based on the cached temporary office file when the version of the finally generated file does not meet the preset version requirements, the efficiency of office file management is further improved.
[0024] In some possible embodiments, generating a template file based on the office file to be processed includes:
[0025] Save the office file to be processed as an XML file, and rewrite the suffix name of the XML file to convert it into a temporary template file;
[0026] Use a preset text editor to read the content of the temporary template file, perform format processing on the content of the temporary template file based on preset format processing rules, and overwrite and save the processed content to the temporary template file to obtain the template file.
[0027] In the embodiments of the present application, by performing format processing on the temporarily converted template file according to preset processing rules, the search efficiency of template variables can be improved, thereby further improving the efficiency of office file management.
[0028] In some possible embodiments, the file management method based on a template engine further includes:
[0029] In response to a user's template variable editing request for the office file to be processed, feedback a template variable editing page based on the XML file;
[0030] Obtain the editing content submitted by the user based on the template variable editing page, generate a modified XML file based on the editing content, and rewrite the suffix name of the modified XML file to convert it into the temporary template file.
[0031] In the embodiments of the present application, when the user needs to edit template variables, by feedbacking a template variable editing page based on the XML file converted from the original office file, it is avoided that the edited variables appear abnormally after format conversion, further improving the reliability and efficiency of office file management.
[0032] In some possible embodiments, the conversion process of the version conversion service includes:
[0033] Read and parse the data information of the file to be converted to generate an original intermediate file;
[0034] Reorganize the data information of the original intermediate file according to the structured standard rules of the required version to obtain an intermediate file to be converted;
[0035] Load based on the intermediate file to be converted to obtain a file after version conversion.
[0036] In the embodiments of the present application, by parsing the data information of the file to be converted and reorganizing it according to the structured standard rules of the required version, a file after version conversion is generated based on the reorganized data information, thereby further improving the reliability and efficiency of office file management.
[0037] In a second aspect, the embodiments of the present application provide a file management device based on a template engine, including:
[0038] A template file generation module, configured to obtain a to-be-processed office file and a to-be-processed content attachment, and generate a template file based on the to-be-processed office file;
[0039] A temporary file generation module, configured to generate a temporary office file based on the template file and the to-be-processed content attachment by using a preset template engine;
[0040] A first file output module, configured to, when determining that the version of the temporary office file matches the preset output requirement information, use the temporary office file as the final office file and output it;
[0041] A second file output module, configured to, when determining that the version of the temporary office file does not match the preset output requirement information, call a preset version conversion service to perform version conversion on the temporary office file, and use the temporarily office file after version conversion as the final office file and output it.
[0042] In a third aspect, the embodiments of the present application provide an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in any one of the embodiments of the first aspect can be implemented.
[0043] In a fourth aspect, the embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the method described in any one of the embodiments of the first aspect can be implemented.
[0044] In a fifth aspect, the embodiments of the present application provide a computer program product, which includes a computer program. When the computer program is executed by a processor, the method described in any one of the embodiments of the first aspect can be implemented. Description of the Drawings
[0045] To more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the attached drawings required for the embodiments of the present application. It should be understood that the following attached drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation of the scope. For those of ordinary skill in the art, without creative efforts, other relevant attached drawings can also be obtained based on these attached drawings.
[0046] Figure 1 A flowchart of a file management method based on a template engine provided for an embodiment of the present application;
[0047] Figure 2 A schematic structural diagram of a file management device based on a template engine provided for an embodiment of the present application;
[0048] Figure 3 A schematic structural diagram of an electronic device provided for an embodiment of the present application. Detailed implementation manners
[0049] The following will describe the technical solutions in the embodiments of the present application in conjunction with the attached drawings in the embodiments of the present application.
[0050] It should be noted that: similar reference numerals and letters represent similar items in the following attached drawings. Therefore, once an item is defined in one attached drawing, it does not need to be further defined and explained in subsequent attached drawings. At the same time, in the description of the present application, terms such as "first" and "second" are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0051] As Figure 1 shown, an embodiment of the present application provides a file management method based on a template engine, which may include the steps:
[0052] S1. Obtain the office file to be processed and the content attachment to be processed, and generate a template file based on the office file to be processed.
[0053] Specifically, the office file to be processed is an office file that the user prepares in advance and will be converted into a template, such as a word document file. The content attachment to be processed is a file of the data content that the user wants to fill in the template.
[0054] After obtaining the office file to be processed, it can be converted into a template file based on a specific processing flow. Exemplarily, the input office file to be processed is a word file (such as a file with the suffix.docx). By saving the word file as an XML file (which can be named test.xml), and then renaming the suffix of the test.xml file to obtain a test.ftl file, which is used as the template file corresponding to the office file to be processed.
[0055] S2. Generate a temporary office file based on the template file and the content attachment to be processed using a preset template engine.
[0056] It should be noted that corresponding temporary office files can be generated based on the template file and the content attachment to be processed using a template engine such as Freemaker. Exemplarily, by creating a wordParamsMap (a Map object for storing Word document parameters) to read the attachment file and convert it into base64-encoded data and other encoded data respectively as values, and calling the process method provided by the freemark.jar package to scan the test.ftl file (template file), and then replacing the corresponding value for the placeholder at the position where the placeholder (such as ${key}) is scanned to generate a temporary office file.
[0057] It should be noted that the temporary office file here is a file with the same version as the file to be processed. For example, if the file to be processed is a word2007 version (docx file), then the temporary office file here is also a word2007 version (docx file).
[0058] S3. When it is determined that the version of the temporary office file matches the preset output requirement information, use the temporary office file as the final office file and output it.
[0059] It should be noted that the user can configure the version of the file to be output in the configuration file of the file management system (such as a file with the suffix.yml). For example, the word2007 version (docx file). When it is determined that the version of the temporary office file is the same as the version configured in this configuration file (that is, the version of the temporary office file matches the preset output requirement information), then directly use the temporary office file as the final office file and output this file.
[0060] S4. When it is determined that the version of the temporary office file does not match the preset output requirement information, call the preset version conversion service to perform version conversion on the temporary office file, and use the temporarily office file after version conversion as the final office file and output it.
[0061] It should be noted that when it is determined that the version of the temporary office file is different from the version configured in this configuration file (that is, the version of the temporary office file does not match the preset output requirement information), then the temporary office file needs to be version-converted before output. Exemplarily, when the temporary office file is a word2003 version (doc file), and the version of the file that the user configures to output is a word2007 version (docx file), then it is necessary to call the preset version conversion service to perform version conversion on the temporary office file to obtain a file with the word2007 version (docx file) and output it.
[0062] The version conversion service can provide various conversion methods. As a possible implementation, a new empty template file (with the version being the version of the file the user wants to output) can be created first, the temporary office file can be opened and loaded, the document content in the temporary office file can be traversed and the format can be converted, and the document after format conversion can be written into the new empty template file to obtain the final office file after version conversion.
[0063] Based on this, by configuring the version conversion rules, after the system generates a temporary office file based on the template engine, office files of different versions can be generated according to user needs, thereby effectively improving the efficiency of office file management.
[0064] In some possible embodiments, in step S1, generating a template file based on the office file to be processed may include:
[0065] S101. When it is determined that the version of the office file to be processed is inconsistent with the recognized version of the template engine, call the version conversion service to perform version conversion on the office file to be processed;
[0066] S102. Generate a template file based on the office file to be processed after version conversion.
[0067] It should be noted that the template engine usually can only recognize file tags of a specific version. For example, the template engine is configured to generate a document file based on a template of the word2003 version (doc file), while the user's local document processing software is the word2016 version. If the word template of the word2016 version is directly converted to an ftl file and imported into the template engine, the template engine cannot recognize the tag information of the ftl file and cannot generate the corresponding word file.
[0068] Therefore, after obtaining the office file to be processed, it is necessary to first determine whether the version of the office file to be processed is consistent with the recognized version of the template engine. If so, it is processed normally; otherwise, it is necessary to call the version conversion service to perform version conversion on the office file to be processed, and then generate a template file based on the office file to be processed after version conversion.
[0069] Based on this, by configuring the version conversion rules, input files of different versions can be converted into versions that the template engine can recognize, thereby effectively improving the compatibility of office file management.
[0070] In some possible embodiments, the file management method based on the template engine may further include:
[0071] S501. In response to the user's online editing request for the final office file, determine whether the version of the final office file meets the preset version requirements;
[0072] S502. If so, convert it to an HTML file based on the final office file, and feedback an online editing page based on the HTML file.
[0073] S503. If not, call the version conversion service to perform version conversion on the temporary office file, so as to convert it to an HTML file based on the final office file after version conversion, and feedback an online editing page based on the HTML file.
[0074] Since the office file generated by the template engine is static content and does not have the function of online editing, when the user has a need to perform online editing on the generated office file, other technologies or services (such as Office, Google Docs, etc.) can be called to provide the online editing function for the office file. However, these services usually require the user to have the corresponding account and subscription, and their functions and compatibility may vary depending on the service provider and the user's subscription.
[0075] Based on this, the embodiment of the present application can convert the generated final office file into HTML format, and then use Web technologies (such as JavaScript and CSS, etc.) to create an editable area on the web page, so that the user can perform operations such as text editing and format setting in this area.
[0076] It should be noted that due to version issues, doc files below the word2003 version cannot be directly converted to HTML format for online editing, but need to be converted to docx files first and then to HTML format to achieve the function of online editing.
[0077] Therefore, when responding to the user's online editing request for the final office file, if it is determined that the version of the final office file does not meet the preset version requirements, first call the version conversion service to perform version conversion on the temporary office file, and then convert the final office file after version conversion into an HTML file, and feedback an online editing page based on the HTML file.
[0078] Based on this, by providing the file online editing function and calling the version conversion service to perform version conversion when the generated office file does not meet the version requirements, the online editing needs of users for different version files are met, and the efficiency of office file management is further improved.
[0079] In some possible embodiments, after step S2, it may further include:
[0080] S201. When it is determined that the version of the temporary office file meets the preset version requirements, cache the temporary office file.
[0081] S202. In response to a user's online editing request for a final office document, when it is determined that the version of the final office document does not meet the preset version requirements, convert the cached temporary office document into an HTML file, and feedback an online editing page corresponding to the final office document based on the HTML file.
[0082] It should be noted that after generating the temporary office document, if the temporary office document meets the preset version requirements (for example, the preset version requirements are docx files above word2007 version), the temporary office document can be cached.
[0083] When responding to a user's online editing request for a final office document, if it is determined that the version of the final office document does not meet the preset version requirements, for example, if the finally generated file is a doc file of word2003 version and does not meet the above preset version requirements, the above cached corresponding temporary office document can be directly called to be converted into an HTML file to achieve the function of online editing.
[0084] Based on this, by caching the temporary office document generated by the template engine and, when the version of the finally generated file does not meet the preset version requirements, feedbacking the online editing page based on the cached temporary office document, there is no need to perform version conversion on the final office document, thereby further improving the efficiency of office document management.
[0085] In some possible embodiments, in step S1, generating a template file based on the office document to be processed may include:
[0086] S111. Save the office document to be processed as an XML file, and rewrite the suffix name of the XML file to convert it into a temporary template file;
[0087] S112. Use a preset text editor to read the content of the temporary template file, perform format processing on the content of the temporary template file based on the preset format processing rules, and overwrite and save the content after format processing to the temporary template file to obtain the template file.
[0088] It should be noted that in the process of converting the office document to be processed into a template file, for example, after saving the office document to be processed as an XML file and rewriting its suffix name to.ftl to obtain a temporary template file, the content of the temporary template file can be read by a text editor at this time, and then the content can be processed based on the preset format processing rules, and finally, the content after format processing is overwritten and saved to the temporary template file as the template file for use.
[0089] Exemplarily, the format processing may include clearing specific types of characters, replacing or adding specific symbols, etc., which can make it more convenient to find and set variables and placeholders in the template file.
[0090] Based on this, by processing the temporarily generated template file after format conversion according to the preset processing rules, the search efficiency of template variables can be improved, thereby further enhancing the efficiency of office document management.
[0091] In some possible embodiments, the file management method based on a template engine may further include:
[0092] S601. In response to a user's template variable editing request for a to-be-processed office document, a template variable editing page is fed back based on an XML file.
[0093] S602. Obtain the editing content submitted by the user based on the template variable editing page, generate a modified XML file based on the editing content, and rewrite the suffix name of the modified XML file to convert it into a temporarily generated template file.
[0094] It should be noted that when a user needs to edit the template variables of a to-be-processed office document, if directly editing and setting in the to-be-processed office document (word file), since the variables originally set may become abnormal (for example, they may be accidentally split) after the word file (such as docx, etc.) is saved as an XML file, therefore, a template variable editing page can be fed back based on the converted XML file to provide the function of editing template variables. Exemplarily, the content of the XML file can be read based on a text editor, and a page for editing template variables can be generated based on this content.
[0095] Based on this, when a user needs to edit template variables, by feeding back a template variable editing page based on the XML file converted from the original office document, the abnormality of the edited variables during the process of converting to an XML file is avoided, further improving the reliability and efficiency of office document management.
[0096] In some possible embodiments, the conversion process of the version conversion service may include:
[0097] Read and parse the data information of the file to be converted to generate an original intermediate file.
[0098] Re-organize the data information of the original intermediate file according to the structured standard rules of the required version to obtain an intermediate file to be converted.
[0099] Load based on the intermediate file to be converted to obtain a file after version conversion.
[0100] It should be noted that the .doc format is the document format of the early versions of Microsoft Word (such as word97-2003), which uses binary format to store text, formatting and other file metadata; since this version of the file uses an earlier file format, it may take up a large space when stored and transmitted. The .docx format is the default file format of Microsoft Word 2007 and later versions, which uses the XML-based open file format (OpenXML) to store text, formatting and other file metadata; compared with the .doc format, the .docx format has better file compression performance, a relatively small file size, and an XML-based structure that makes it easier to process and parse.
[0101] As a possible implementation method, in the process of calling the version conversion service to perform version conversion on a file, the file to be converted (the original .doc file) is first parsed, and the data information such as the text, format and other metadata therein is read to obtain the original intermediate file; then, the data information in the original intermediate file is reorganized according to the structured standard rules of the required version (such as the requirements of the .docx format) to obtain the intermediate file to be converted. For example, since the .docx file is based on the XML format, the above data information needs to be converted into the XML format and structured and marked according to the Open XML standard; finally, based on the reorganized data (the intermediate file to be converted), a new version-converted file is finally generated by creating an XML file, adding necessary metadata and resources, and other steps.
[0102] Based on this, by parsing the data information of the file to be converted and reorganizing it according to the structured standard rules of the required version, the version-converted file is generated based on the reorganized data information, thereby further improving the reliability and efficiency of office document management.
[0103] Please refer to Figure 2 , Figure 2 FIG. 1 shows a block diagram of a file management device based on a template engine provided by some embodiments of the present application. It should be understood that the file management device based on a template engine is similar to the above-mentioned Figure 1 Corresponding to the method embodiment, each step involved in the above method embodiment can be executed. The specific functions of the file management device based on the template engine can be found in the description above. To avoid repetition, the detailed description is appropriately omitted here.
[0104] Figure 2 The file management device based on the template engine includes at least one software function module that can be stored in a memory in the form of software or firmware or fixed in the file management device based on the template engine, and the file management device based on the template engine includes:
[0105] A template file generation module 210 is configured to obtain an office file to be processed and a content attachment to be processed, and generate a template file based on the office file to be processed;
[0106] A temporary file generation module 220 is configured to generate a temporary office file based on the template file and the content attachment to be processed by using a preset template engine;
[0107] A first file output module 230 is configured to, when it is determined that the version of the temporary office file matches the preset output requirement information, use the temporary office file as the final office file and output it;
[0108] A second file output module 240 is configured to, when it is determined that the version of the temporary office file does not match the preset output requirement information, call a preset version conversion service to perform version conversion on the temporary office file, and use the temporarily office file after version conversion as the final office file and output it.
[0109] It can be understood that the above device item embodiments correspond to the method item embodiments of the present invention. A file management device based on a template engine provided by the embodiments of the present invention can implement the file management method based on a template engine provided by any one of the method item embodiments of the present invention.
[0110] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above-described devices can refer to the corresponding processes in the foregoing methods, and will not be elaborated herein.
[0111] As Figure 3 shown, some embodiments of the present application provide an electronic device 300, which includes: a memory 310, a processor 320, and a computer program stored on the memory 310 and executable on the processor 320. Among them, when the processor 320 reads the program from the memory 310 through the bus 330 and executes the program, it can implement the methods of any of the embodiments included in the above file management method based on a template engine.
[0112] The processor 320 can process digital signals and can include various computing architectures. For example, a complex instruction set computer architecture, a reduced instruction set computer architecture, or an architecture that implements a combination of multiple instruction sets. In some examples, the processor 320 may be a microprocessor.
[0113] The memory 310 can be used to store instructions executed by the processor 320 or data related to the instruction execution process. These instructions and / or data can include code for implementing some or all of the functions of one or more modules described in the embodiments of the present application. The processor 320 of the embodiments of the present disclosure can be used to execute the instructions in the memory 310 to implement the methods shown above. The memory 310 includes dynamic random access memory, static random access memory, flash memory, optical memory, or other memories well known to those skilled in the art.
[0114] Some embodiments of the present application also provide a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it executes the method described in the method embodiments.
[0115] Some embodiments of the present application also provide a computer program product. When the computer program product runs on a computer, it causes the computer to execute the method described in the method embodiments.
[0116] It should be noted that the embodiments in this specification are all described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other. For device embodiments, since they are basically similar to the method embodiments, the description is relatively simple. For related parts, reference can be made to the partial description of the method embodiments.
[0117] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are only illustrative. For example, the flowcharts and block diagrams in the drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order from that marked in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0118] In addition, in each embodiment of the present application, each functional module can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0119] If the above-mentioned function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0120] The above are only the embodiments of the present application and are not used to limit the protection scope of the present application. For those skilled in the art, the present application can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0121] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present application, and all should be covered by the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
[0122] Note that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
Claims
1. A file management method based on a template engine, characterized in that Including: Obtain the office document to be processed and the content attachment to be processed, and generate a template file based on the office document to be processed; Generate a temporary office document based on the template file and the content attachment to be processed by using a preset template engine; When it is determined that the version of the temporary office document matches the preset output requirement information, use the temporary office document as the final office document and output it; When it is determined that the version of the temporary office document does not match the preset output requirement information, call a preset version conversion service to perform version conversion on the temporary office document, so as to use the temporarily office document after version conversion as the final office document and output it.
2. The file management method based on a template engine according to claim 1, wherein The generating a template file based on the office document to be processed includes: When it is determined that the version of the office document to be processed is inconsistent with the recognition version of the template engine, call the version conversion service to perform version conversion on the office document to be processed; Generate a template file based on the office document to be processed after version conversion.
3. The file management method based on a template engine according to claim 1, wherein It further includes: In response to the user's online editing request for the final office document, determine whether the version of the final office document meets the preset version requirements; If so, convert the final office document into an HTML file, and feedback an online editing page based on the HTML file; If not, call the version conversion service to perform version conversion on the temporary office document, so as to convert the final office document after version conversion into an HTML file, and feedback an online editing page based on the HTML file.
4. The file management method based on a template engine according to claim 1, wherein After generating the temporary office document based on the template file and the content attachment to be processed by using the preset template engine, it further includes: When it is determined that the version of the temporary office document meets the preset version requirements, cache the temporary office document; In response to the user's online editing request for the final office document, when it is determined that the version of the final office document does not meet the preset version requirements, convert the cached temporary office document into an HTML file, and feedback an online editing page corresponding to the final office document based on the HTML file.
5. The file management method based on a template engine according to claim 1, wherein The generating a template file based on the office document to be processed includes: Save the office document to be processed as an XML file, and rewrite the suffix name of the XML file to convert it into a temporary template file; Use a preset text editor to read the content of the temporary template file, perform format processing on the content of the temporary template file based on preset format processing rules, and overwrite and save the content after format processing to the temporary template file to obtain the template file.
6. The file management method based on a template engine according to claim 5, wherein It further includes: In response to the user's template variable editing request for the office document to be processed, feedback a template variable editing page based on the XML file; Obtain the editing content submitted by the user based on the template variable editing page, generate a modified XML file based on the editing content, and rewrite the suffix name of the modified XML file to convert it into the temporary template file.
7. The file management method based on a template engine according to claim 1, wherein The conversion process of the version conversion service includes: Read and parse the data information of the file to be converted to generate the original intermediate file; Reorganize the data information of the original intermediate file according to the structured standard rules of the required version to obtain the intermediate file to be converted; Load based on the intermediate file to be converted to obtain the file after version conversion.
8. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and executable on the processor. Among them, when the processor executes the program, it can implement the file management method based on the template engine described in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is run by the processor, it executes the file management method based on the template engine described in any one of claims 1-7.
10. A computer program product, characterized in that, The computer program product includes a computer program, and when the computer program is executed by the processor, it implements the file management method based on the template engine described in any one of claims 1-7.