Method, device and equipment for dynamically exporting Word document at server side and storage medium

By configuring the basic export template, data model, and runtime environment, and utilizing Apache ECharts HTTPExportServer and Poi-ti syntax, Word documents can be dynamically exported, solving the problem of low efficiency in enterprise report writing and achieving automated generation.

CN119129564APending Publication Date: 2024-12-13CHENGDU EACOM TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411246835.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

Current technologies are inefficient for writing enterprise reports and cannot achieve automated updates.

Method used

By configuring the basic export template, data model, and runtime environment, and utilizing Apache EChartsHTTPExportServer and Poi-ti syntax, Word documents can be dynamically exported, including automatic filling and rendering of text and chart data.

Benefits of technology

It enables the automated generation of enterprise reports, improving writing efficiency and reducing manual operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119129564A_ABST
    Figure CN119129564A_ABST
Patent Text Reader

Abstract

The invention discloses a method, device and equipment for dynamically exporting a Word document at a server and a storage medium. Comprising the following steps that a basic export template, a data model and a running environment are configured in advance, the basic export template refers to a universal Word template, and the running environment refers to a deployed Apache EChartsHTTPExport Server; to-be-exported data and a corresponding basic export template are determined, and the to-be-exported data at least comprises text data; and filling the data model with the to-be-exported data, and rendering the Word document in combination with the basic export template. The problem that in the prior art, due to the fact that Word documents need to be written manually, efficiency is low is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information processing technology, and in particular to a method, device, equipment and storage medium for dynamically exporting a Word document on a server side. Background Art

[0002] With the advent of the information age, enterprises need to prepare a large number of reports, such as weekly, monthly, and quarterly reports. Currently, most companies write these reports manually, which is not only inefficient but also unable to automatically update. Therefore, it is urgent to design a technical solution that can automatically export reports. Summary of the invention

[0003] In view of the above problems, the embodiments of the present invention solve the problem of low efficiency caused by the need to manually write Word documents in the prior art by providing a method, apparatus, device and storage medium for dynamically exporting Word documents on a server.

[0004] The embodiments of the present application provide a method, apparatus, device and storage medium for dynamically exporting a Word document from a server.

[0005] In a first aspect, the present invention provides a method, apparatus, device and storage medium for dynamically exporting a Word document on a server, including: pre-configuring a basic export template, a data model and an operating environment, wherein the basic export template refers to a general Word template, and the operating environment refers to a deployed ApacheEChartsHTTPExportServer;

[0006] Determine the data to be exported and the corresponding basic export template, wherein the data to be exported includes at least text data;

[0007] Fill the data to be exported into the data model, and render the Word document based on the basic export template.

[0008] In some embodiments, pre-configuring a basic export template, a data model, and an operating environment includes: creating a basic export template using Poi-ti syntax, the basic export template including at least one tag, and using a specific tag syntax in the basic export template to indicate a data insertion point and a logical control structure;

[0009] Build a data model based on the tags in the basic export template;

[0010] Install Canvas dependencies in ApacheEChartsHTTPExportServer and complete the configuration according to the server requirements.

[0011] In some embodiments, the data to be exported is filled into the data model, and combined with the basic export template, a Word document is rendered, specifically including:

[0012] Determine whether the data to be exported contains chart data;

[0013] If so, assemble the request link according to the ECharts data format and request ApacheEChartsHTTPExportServer to obtain the base64 string of the chart data;

[0014] Decode the base64 string of the chart data to obtain the image file corresponding to the chart data;

[0015] Fill the text data and image files into the data model;

[0016] If not, fill the data to be exported into the data model.

[0017] In some embodiments, if no, after filling the data to be exported into the data model, the method further includes:

[0018] Through Poi-ti's template rendering engine, the data model is applied to the basic export template to generate a Word document.

[0019] In a second aspect, the present invention further provides a device for dynamically exporting a Word document on a server, comprising:

[0020] Configuration module, used to pre-configure the basic export template, data model and operating environment, where the basic export template refers to the general Word template and the operating environment refers to the deployed ApacheEChartsHTTPExportServer;

[0021] A determination module, used to determine the data to be exported and the corresponding basic export template, wherein the data to be exported includes at least text data;

[0022] The rendering module is used to fill the data to be exported into the data model and render the Word document in combination with the basic export template.

[0023] In some embodiments, the configuration module includes:

[0024] A creation unit, used to create a basic export template using Poi-ti syntax, the basic export template includes at least one tag, and the basic export template uses a specific tag syntax to indicate a data insertion point and a logic control structure;

[0025] A construction unit is used to construct a data model according to the tags in the basic export template;

[0026] Installation unit, used to install Canvas dependencies in ApacheEChartsHTTPExportServer and complete the configuration according to the server requirements.

[0027] In some embodiments, the rendering module includes:

[0028] A judging unit, used for judging whether the data to be exported contains chart data;

[0029] The request unit is used to assemble the request link according to the ECharts data format and request ApacheEChartsHTTPExportServer to obtain the base64 string of the chart data;

[0030] An acquisition unit, used for decoding the base64 character string of the chart data to acquire the image file corresponding to the chart data;

[0031] A first filling unit, used to fill text data and image files into the data model;

[0032] The second filling unit is used to fill the data to be exported into the data model.

[0033] In some embodiments, the rendering unit further includes:

[0034] The application unit is used to apply the data model to the basic export template through Poi-ti's template rendering engine to generate a Word document.

[0035] In a third aspect, an embodiment of the present application further provides an electronic device, including: a processor and a memory, wherein the processor is used to call a program in the memory so that the electronic device executes a method for dynamically exporting a Word document on a server side.

[0036] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores instructions, and when the instructions are executed, enables the computer to execute a method for dynamically exporting a Word document on a server.

[0037] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: by pre-configuring the basic export template, data model and operating environment; determining the data to be exported and the corresponding basic export template; filling the data to be exported into the data model, and rendering the Word document in combination with the basic export template. This solves the problem of low efficiency caused by the need to manually write Word documents in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0039] Figure 1 A flowchart of a method for dynamically exporting a Word document on a server provided in an embodiment of the present application;

[0040] Figure 2 A schematic diagram of an exported Word document provided in an embodiment of the present application;

[0041] Figure 3 A schematic diagram of a pre-configured method flow provided in an embodiment of the present application;

[0042] Figure 4 A flowchart of a method for rendering a Word document provided in an embodiment of the present application;

[0043] Figure 5 A schematic block diagram of a device for dynamically exporting a Word document on a server provided in an embodiment of the present application;

[0044] Figure 6 A schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0046] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0047] Embodiment 1

[0048] See also Figure 1 , Figure 1 A flowchart of a method for dynamically exporting a Word document on a server provided in an embodiment of the present application, the method comprising the following steps:

[0049] S10: Pre-configure the basic export template, data model and operating environment, where the basic export template refers to the general Word template and the operating environment refers to the deployed ApacheEChartsHTTPExportServer.

[0050] Specifically, the basic export template is a container for storing text content and various data models. The basic export template adopts the form of a general Word template, that is, users can customize the Word template according to their own needs without having to redevelop a new template, thereby reducing the difficulty of development and improving work efficiency. At the same time, in order to realize the dynamic nature of Word documents, it is also necessary to set up a data model so that relevant data can be filled into the data model later, thereby obtaining a dynamic Word document.

[0051] In addition, in order to meet the actual application scenarios, it is also necessary to set up a related operating environment. In this embodiment, the operating environment is set to the deployed ApacheEChartsHTTPExportServer. ApacheEChartsHTTPExportServer is a lightweight Web server that provides a flexible and easy-to-use interface for client calls and supports multiple output formats, including SVG, PNG, JPEG, etc., which can be used to quickly export chart data and convert it into image format.

[0052] S20: Determine the data to be exported and the corresponding basic export template, wherein the data to be exported includes at least text data.

[0053] Specifically, the data to be exported refers to the original data that needs to be exported, which may include but is not limited to text data, chart data, etc., wherein text data refers to data in pure text form, such as meeting minutes, work plans, etc.

[0054] S30: Fill the data to be exported into the data model, and render the Word document in combination with the basic export template.

[0055] Specifically, the process of filling the data to be exported into the data model is the process of mapping the data to be exported to the data model, that is, filling each field in the data to be exported into the corresponding field in the data model, so that a complete Word document can be formed.

[0056] Then, combined with the basic export template, the template rendering engine is used to apply the data model to the basic export template to generate the final Word document. Figure 2 A schematic diagram of an exported Word document provided in an embodiment of the present application is shown, such as Figure 2As shown in the figure, when the data to be exported includes the name, gender and physical fitness five-dimensional radar chart related data, the exported Word document is as follows Figure 2 shown.

[0057] In summary, the method for dynamically exporting Word documents from the server provided by the present application is to pre-configure the basic export template, data model and operating environment, wherein the basic export template refers to the general Word template, and the operating environment refers to the deployed ApacheEChartsHTTPExportServer; determine the data to be exported and the corresponding basic export template, wherein the data to be exported includes at least text data; fill the data to be exported into the data model, and render the Word document in combination with the basic export template. Thus, the problem of low efficiency caused by the need to manually write Word documents in the prior art is solved.

[0058] As a possible implementation, please refer to Figure 3 , Figure 3 A schematic diagram of a pre-configuration method flow provided in an embodiment of the present application, S10: pre-configure a basic export template, a data model, and an operating environment, wherein the basic export template refers to a general Word template, and the operating environment refers to a deployed Apache ECharts HTTP Export Server, including the following steps:

[0059] S11: Use Poi-ti syntax to create a basic export template, the basic export template contains at least one tag, and the basic export template uses a specific tag syntax to indicate the data insertion point and the logic control structure.

[0060] Specifically, Poi-ti is an open source Java library that can parse data in various formats such as Excel, CSV, XML, etc., and supports custom templates, which is very suitable for making report applications. Poi-ti supports the use of tag syntax to specify data insertion points and logical control structures, which makes it very convenient for us to create basic export templates that meet our needs.

[0061] S12: Build a data model according to the tags in the basic export template.

[0062] Specifically, a data model is a concept used to represent data structure. It is an abstract description of the essential attributes and interrelationships of a thing or phenomenon in the real world. Here, we use the tags in the basic export template as the input of the data model. By analyzing and processing these tags, we can build a complete data model.

[0063] S13: Install Canvas dependencies in ApacheEChartsHTTPExportServer and complete the configuration according to the server requirements.

[0064] Specifically, ApacheEChartsHTTPExportServer is a lightweight web server that can provide external services through API. We need to install Canvas dependency in ApacheEChartsHTTPExportServer because it provides a chart drawing function that can help us display data more easily. In addition, we can also configure various parameters of ApacheEChartsHTTPExportServer according to our needs, such as IP address, port number, etc.

[0065] As a possible implementation, please refer to Figure 4 , Figure 4 A flowchart of a method for rendering a Word document provided in an embodiment of the present application, S30: filling the data to be exported into the data model, and rendering the Word document in combination with the basic export template, including the following steps:

[0066] S31: Determine the data to be exported and the corresponding basic export template, wherein the data to be exported includes at least text data.

[0067] S32: Determine whether the data to be exported includes chart data.

[0068] S33: If so, assemble the request link according to the ECharts data format, and request ApacheEChartsHTTPExportServer to obtain the base64 string of the chart data.

[0069] Specifically, if the data to be exported contains chart data, you need to format these data into the data format supported by ECharts first, and then send them to ApacheEChartsHTTPExportServer for processing. ApacheEChartsHTTPExportServer will return an image, which is the image corresponding to our chart data.

[0070] S34: Decode the base64 string of the chart data to obtain a picture file corresponding to the chart data.

[0071] S35: Fill the text data and image files into the data model.

[0072] S36: If not, fill the data to be exported into the data model.

[0073] As a possible implementation, please refer to Figure 4 , in S36: if not, after filling the data to be exported into the data model, the following steps are also included:

[0074] S37: Apply the data model to the basic export template through Poi-ti's template rendering engine to generate a Word document.

[0075] Specifically, the process of filling the data to be exported into the data model is the process of mapping the data to be exported to the data model, that is, filling each field in the data to be exported into the corresponding field in the data model, so that a complete Word document can be formed. Then, combined with the basic export template, the data model is applied to the basic export template using the template rendering engine to generate the final Word document.

[0076] Embodiment 2

[0077] The present application also provides a device for dynamically exporting Word documents from a server, such as Figure 5 As shown, the device comprises:

[0078] Configuration module 400, used to pre-configure a basic export template, a data model and an operating environment, wherein the basic export template refers to a general Word template, and the operating environment refers to a deployed ApacheEChartsHTTPExportServer;

[0079] A determination module 500, used to determine the data to be exported and the corresponding basic export template, wherein the data to be exported includes at least text data;

[0080] The rendering module 600 is used to fill the data to be exported into the data model and render the Word document in combination with the basic export template.

[0081] In one possible design, configuration module 400 includes:

[0082] A creating unit 410 is used to create a basic export template using Poi-ti syntax, wherein the basic export template includes at least one tag, and a specific tag syntax is used in the basic export template to indicate a data insertion point and a logic control structure;

[0083] A construction unit 420, configured to construct a data model according to tags in the basic export template;

[0084] The installation unit 430 is used to install the Canvas dependency in the ApacheEChartsHTTPExportServer and complete the configuration according to the server requirements.

[0085] In one possible design, the rendering module 600 includes:

[0086] The determination unit 610 is used to determine whether the data to be exported contains chart data;

[0087] The request unit 620 is used to assemble a request link according to the data format of ECharts, and request ApacheEChartsHTTPExportServer to obtain a base64 string of the chart data;

[0088] An acquisition unit 630 is used to decode the base64 character string of the chart data to acquire a picture file corresponding to the chart data;

[0089] A first filling unit 640, used to fill text data and image files into the data model;

[0090] The second filling unit 650 is used to fill the data to be exported into the data model.

[0091] In a possible design, the rendering unit 600 further includes:

[0092] The application unit 660 is used to apply the data model to the basic export template through the template rendering engine of Poi-ti to generate a Word document.

[0093] Regarding the devices in the above-mentioned embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments of the method, and will not be elaborated on here. The embodiment of the present application also provides an electronic device, including: a processor and a memory, the processor is used to call a program in the memory to enable the electronic device to perform a method as provided in any of the above-mentioned method embodiments.

[0094] Embodiment 3

[0095] Reference Figure 6 The embodiment of the present application further provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus.

[0096] Memory, used to store computer programs;

[0097] In one embodiment of the present application, the processor is used to execute the program stored in the memory to implement the small target detection, tracking and interference method provided by any of the aforementioned method embodiments, and the role it plays is similar and will not be repeated here.

[0098] It should be understood by those skilled in the art that part or all of the above-mentioned mechanisms can be implemented by circuit hardware structures. Similarly, part or all of the above-mentioned methods can also be implemented by software function units executed by circuit hardware structures. The circuit hardware structure provided in the embodiment of the present application can be implemented in the form of transistors, integrated circuit chips, and systems on chips (SoC, System On Chip). If the functions described in the embodiment of the present application are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or part of the technical solution that contributes to the prior art or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0099] Embodiment 4

[0100] The embodiment of the present application also provides a non-volatile computer-readable storage medium, on which a computer program is stored, and when the program is executed by the processor, the small target detection, tracking and interference method provided in any embodiment of the present application is implemented. The computer-readable storage medium can be a flash memory, a hard disk, a multimedia card, a card-type memory (for example, SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a disk, an optical disk, a server, an App application store, etc.

[0101] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0102] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0103] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0104] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0105] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0106] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for dynamically exporting Word documents on the server side. It is characterized in that The steps include: Pre-configure a basic export template, a data model, and an operating environment, wherein the basic export template refers to a general Word template, and the operating environment refers to a deployed ApacheEChartsHTTPExportServer; Determining data to be exported and a corresponding basic export template, wherein the data to be exported includes at least text data; Fill the data to be exported into the data model, and render the Word document based on the basic export template.

2. The method according to claim 1, It is characterized in that The pre-configured basic export template, data model and operating environment include: Using Poi-ti syntax to create the basic export template, the basic export template includes at least one tag, and the basic export template uses a specific tag syntax to indicate a data insertion point and a logic control structure; Building a data model according to the tags in the basic export template; Install Canvas dependencies in ApacheEChartsHTTPExportServer and complete the configuration according to the server requirements.

3. The method according to claim 1, It is characterized in that The method of filling the data to be exported into the data model and rendering the Word document in combination with the basic export template specifically includes: Determine whether the data to be exported includes chart data; If so, assemble the request link according to the ECharts data format and request ApacheEChartsHTTPExportServer to obtain the base64 string of the chart data; Decode the base64 string of the chart data to obtain the image file corresponding to the chart data; Fill the text data and the picture file into the data model; If not, fill the data to be exported into the data model.

4. The method according to claim 1, It is characterized in that In the case of "if not", after filling the to-be-exported data into the data model, the method further includes: The data model is applied to the basic export template through Poi-ti's template rendering engine to generate a Word document.

5. A device for dynamically exporting Word documents on the server side, It is characterized in that include: A configuration module is used to pre-configure a basic export template, a data model, and an operating environment, wherein the basic export template refers to a general Word template, and the operating environment refers to a deployed ApacheEChartsHTTPExportServer; A determination module, used to determine the data to be exported and the corresponding basic export template, wherein the data to be exported includes at least text data; The rendering module is used to fill the data to be exported into the data model and render the Word document in combination with the basic export template.

6. A device for dynamically exporting Word documents from a server. It is characterized in that The configuration module includes: A creating unit, used to create the basic export template using Poi-ti syntax, wherein the basic export template includes at least one tag, and the basic export template uses a specific tag syntax to indicate a data insertion point and a logic control structure; A construction unit, used to construct a data model according to the tags in the basic export template; Installation unit, used to install Canvas dependencies in ApacheEChartsHTTPExportServer and complete the configuration according to the server requirements.

7. A device for dynamically exporting Word documents from a server. It is characterized in that The rendering module includes: A judging unit, used for judging whether the data to be exported includes chart data; The request unit is used to assemble the request link according to the ECharts data format and request ApacheEChartsHTTPExportServer to obtain the base64 string of the chart data; An acquisition unit, used for decoding the base64 character string of the chart data to acquire the image file corresponding to the chart data; A first filling unit, used to fill the text data and the image file into the data model; The second filling unit is used to fill the data to be exported into the data model.

8. A device for dynamically exporting Word documents from a server. It is characterized in that The rendering unit further includes: The application unit is used to apply the data model to the basic export template through the template rendering engine of Poi-ti to generate a Word document.

9. An electronic device, It is characterized in that include: A processor and a memory, wherein the processor is used to call a program in the memory to enable the electronic device to execute the method according to any one of claims 1 to 4.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed, the computer executes the method according to any one of claims 1 to 4.