Dynamic report generation method and system and application thereof
By parsing and updating the content control identifier and format properties of the xml file, the problem of low report generation is solved, and the dynamic report generation is realized with instant WYSIWYG, simplifying the report production process, and improving efficiency and format consistency.
Patent Information
- Application Number
- CN202510521427.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-08-15
AI Technical Summary
In the field of quantitative investment research, researchers or fund managers need to frequently prepare analysis reports, manually adjusting the format is time-consuming and labor-intensive, and the format is not unified when multiple people collaborate, which affects professionalism and readability. Non-technical personnel cannot independently produce templates. Template development and business needs require technical team access, and traditional placeholders or code generation templates need to be adjusted repeatedly after generation.
By obtaining the initial report template, parsing it into an xml file, extracting the identifier and format attributes of the content control, updating the xml node based on the data mapping table, and using the specified engine rendering as the target report, decoupling the template and data logic, reducing the production threshold, and improving generation efficiency.
It realizes instant-to-what-get report generation, and non-technical personnel can also independently design personalized templates. Developers focus on data logic, improving report generation efficiency and format consistency.
Smart Images

Figure CN120493869A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of automatic processing of graphic and text information, and in particular to a method and system for generating dynamic reports and their applications. Background Art
[0002] In the field of quantitative investment research, researchers or fund managers need to frequently prepare analytical reports (such as strategy backtesting reports and position analysis reports), but manually adjusting the format each time is time-consuming and labor-intensive. When multiple people collaborate, the report format is not uniform, which affects professionalism and readability. Related technologies rely on technical personnel to write code to generate templates. Non-technical personnel cannot independently create templates. Template development and business needs require the integration of technical teams, and the process is lengthy. At the same time, traditional placeholder or code generation templates need to be checked after the complete report is generated. The template and the final report style rules are very different and need to be adjusted repeatedly. Summary of the Invention
[0003] The present application provides a method and system for generating a dynamic report and its application, which solves the technical problem of low report generation efficiency in related technologies and achieves the technical effect of "what you see is what you get".
[0004] In order to achieve the above objectives, the main technical solutions adopted in this application include:
[0005] In a first aspect, an embodiment of the present application provides a method for generating a dynamic report, the method comprising: obtaining an initial report template, the initial report template comprising a fixed content area and a dynamic content area, wherein the dynamic content area is provided with a content control; utilizing a designated engine to parse the initial report template from a word document into an XML file, extracting XML nodes corresponding to the content controls in the XML file, and determining an identifier and format attributes of the content controls based on the extracted XML nodes, wherein the format attributes are used to characterize the data type, style rules, and size and position of the content controls; extracting corresponding dynamic data from a data mapping table based on the identifier, wherein the data mapping table is used to characterize the mapping relationship between the identifier and the corresponding dynamic data; updating the XML nodes based on the format attributes and the dynamic data to obtain an updated XML file; utilizing the designated engine to render the updated XML file into a target report consistent with the format of the initial report template.
[0006] The embodiment of the present application proposes a method for generating a dynamic report, the method comprising: obtaining an initial report template, the initial report template comprising a fixed content area and a dynamic content area, wherein the dynamic content area is provided with a content control; utilizing a designated engine to parse the initial report template from a word document into an XML file, extracting XML nodes corresponding to the content controls in the XML file, and determining an identifier and format attributes of the content controls based on the extracted XML nodes, wherein the format attributes are used to characterize the data type, style rules, and size and position of the content controls; extracting corresponding dynamic data from a data mapping table based on the identifier, wherein the data mapping table is used to characterize the mapping relationship between the identifier and the corresponding dynamic data; updating the XML nodes based on the format attributes and the dynamic data to obtain an updated XML file; utilizing the designated engine to render the updated XML file into a target report consistent with the format of the initial report template, thereby solving the technical problem of low report generation efficiency in related technologies and achieving a what-you-see-is-what-you-get technical effect.
[0007] Optionally, updating the XML node based on the format attribute and the dynamic data includes: updating the node content of the XML node to the corresponding dynamic data; and the node attribute of the XML node inheriting the format attribute of the content control.
[0008] Optionally, the content control is a text control, and the method includes: extracting a text control node corresponding to the text control in the xml file; determining a first identifier and a first format attribute of the text control based on the text control node; extracting corresponding text data from the data mapping table based on the first identifier, and updating the first node content of the text control node to the text data; the first node attribute of the text control node inherits the first format attribute of the text control; using the specified engine, rendering the updated text control node as target text, and replacing the target text into the corresponding text control.
[0009] Optionally, the content control is a table control, and the method includes: extracting a table row node corresponding to the table control in the xml file; determining a second identifier and a second format attribute of the table control based on the table row node; extracting a corresponding data list from the data mapping table based on the second identifier, and dynamically updating the number of nodes and the second node content of the table row node based on the data list; the second node attribute of the table row node inherits the second format attribute of the table control; using the specified engine, rendering the updated table row node as a target table, and replacing the target table with the corresponding table control.
[0010] Optionally, the content control is a picture control, and the method includes: extracting a picture node corresponding to the picture control in the XML file; determining a third identifier and a third format attribute of the picture control based on the picture node; extracting corresponding chart data from the data mapping table based on the third identifier; configuring a velocity engine based on the chart data; generating a corresponding temporary picture using Echarts based on the configured velocity engine; updating the third node content of the picture node based on the temporary picture; the third node attribute of the picture node inherits the third format attribute of the picture control; using the specified engine, rendering the updated picture node as a target picture, and replacing the target picture with the corresponding picture control.
[0011] Optionally, when the data type is a plain text type, the content control is a text control, and the style rules include font size and font color; when the data type is a list type, the content control is a table control, and the style rules include table border style and font style; when the data type is a picture type, the content control is a picture control, and the style rules include picture size and cropping method.
[0012] Optionally, the identifier includes a variable symbol and a variable name, the data mapping table is a key-value pair data structure, the key-value pair data structure is used to represent the mapping relationship between keys and values, the identifier matches the key in the key-value pair data structure, and based on the identifier, the corresponding value in the key-value pair data structure is extracted, and the extracted value is used as the dynamic data.
[0013] Optionally, the initial report template is in doc format or docx format, and the corresponding content control is set using a word development tool module.
[0014] In the second aspect, an embodiment of the present application also provides a dynamic report generation system that can implement the above-mentioned dynamic report generation method, and the system includes: an acquisition module for acquiring an initial report template, the initial report template including a fixed content area and a dynamic content area, wherein the dynamic content area is provided with a content control; a parsing module for using a specified engine to parse the initial report template from a word document into an XML file, extracting the XML nodes corresponding to the content controls in the XML file, and determining the identifier and format attributes of the content controls based on the extracted XML nodes, wherein the format attributes are used to characterize the data type, style rules, and size and position of the content controls; a rendering module for extracting corresponding dynamic data from a data mapping table based on the identifier, wherein the data mapping table is used to characterize the mapping relationship between the identifier and the corresponding dynamic data; updating the XML nodes based on the format attributes and the dynamic data to obtain the updated XML file; and using the specified engine, rendering the updated XML file into a target report consistent with the format of the initial report template.
[0015] Thirdly, the embodiments of the present application also provide the application of the above-mentioned dynamic report generation method in the field of financial quantitative analysis.
[0016] In a fourth aspect, an embodiment of the present application provides a computer device comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the above-mentioned method for generating dynamic reports by executing the computer instructions.
[0017] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to execute the above-mentioned method for generating a dynamic report.
[0018] In a sixth aspect, an embodiment of the present application provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the above-mentioned method for generating a dynamic report. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the specific implementation methods or the description of the prior art. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0020] Figure 1A flowchart of a method for generating a dynamic report provided in an embodiment of the present application;
[0021] Figure 2 A schematic diagram of a dynamic report generation system provided in an embodiment of the present application;
[0022] Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] To make the purpose, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions 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 those skilled in the art without making creative efforts shall fall within the scope of protection of this application.
[0024] In the field of quantitative investment research, researchers or fund managers need to frequently prepare analytical reports (such as strategy backtesting reports and position analysis reports), but manually adjusting the format each time is time-consuming and labor-intensive. When multiple people collaborate, the report format is not uniform, which affects professionalism and readability. Related technologies rely on technical personnel to write code to generate templates. Non-technical personnel cannot independently create templates. Template development and business needs require the integration of technical teams, and the process is lengthy. At the same time, traditional placeholder or code generation templates need to be checked after the complete report is generated. The template and the final report style rules are very different and need to be adjusted repeatedly.
[0025] In order to simplify the research report generation process and improve the efficiency of report production, the embodiment of the present application provides a dynamic report generation method. By decoupling Word template production from data logic, the threshold for report production is lowered, allowing business personnel to independently design personalized Word templates, and developers focus on implementing data logic with clear division of labor, thus achieving decoupling of template production from data logic and improving report generation efficiency.
[0026] 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.
[0027] In this embodiment, a method for generating a dynamic report is provided. Figure 1 This is a flow chart of a method for generating a dynamic report provided in an embodiment of the present application. Figure 1 As shown, the process includes the following steps:
[0028] Step S1: obtaining an initial report template, wherein the initial report template includes a fixed content area and a dynamic content area, wherein the dynamic content area is provided with a content control.
[0029] The initial report template is a Word document. The initial report template includes the layout of each report component to ensure that the final report has the same style and format as the initial report template. The report components include text, table, and image content. Layout refers to presetting the size, position, font format, font size, and font color of each component. Layout also includes text formatting for text, table formatting for table content, and image formatting for image content.
[0030] The initial report template includes fixed content areas and dynamic content areas. Among them, the fixed content area refers to the area that will not change in the report. It is a static area, and the fixed content area remains consistent in different reports. The content in the dynamic content area will be updated according to different data or conditions. The dynamic content area can make the report flexible and adaptable, and can generate personalized reports based on different input data. The content control refers to the container in the dynamic content area used to carry and display specific content, and is used to fill the corresponding dynamic content when generating the report. The content control defines the type, format and layout of the dynamic content. For example, the table control is designated to display tabular data, the text control is designated to display text content, and the image control is designated to display image content. Content controls can ensure that dynamic content is presented in a standardized manner in the report. Use the word development tool module to select and set the corresponding content control.
[0031] Taking strategy reports as an example, a general strategy report template can adapt to various strategy analysis scenarios. In a strategy report template, a text control can be used to display strategy summaries, such as cumulative returns, a table control can be used to display the industry distribution of holdings, and an image control can be used to display a time series daily return trend chart.
[0032] Step S3, using a designated engine to parse the initial report template from a word document into an XML file, extracting the XML nodes corresponding to the content controls in the XML file, and determining the identifier and format attributes of the content controls based on the extracted XML nodes, wherein the format attributes are used to characterize the data type, style rules, and size and position of the content controls.
[0033] Among them, the designated engine is used to convert the word document into an xml file, or render the xml file into a word document. For example, the designated engine can be a docx4j engine. Through the xml file, it is easier to operate and modify the content of the word document. In the parsed xml file, the content control will be represented by a corresponding xml node. Each content control has a corresponding identifier, which is used to uniquely identify the content control. By parsing the xml node corresponding to the content control, the identifier and format attributes corresponding to the content control can be found. Among them, the format attributes are used to define the format of the content of the data stored in the content control (such as text, numbers, dates, etc.), the appearance style of the content control, and the position and layout of the content control in the report.
[0034] Step S5: extracting corresponding dynamic data from a data mapping table based on the identifier, wherein the data mapping table is used to characterize the mapping relationship between the identifier and the corresponding dynamic data; updating the xml node based on the format attribute and the dynamic data to obtain the updated xml file; and using the designated engine, rendering the updated xml file into a target report consistent with the format of the initial report template.
[0035] The data mapping table is a key-value pair data structure, where the key is an identifier and the value is the dynamic data corresponding to the identifier.<string,Object> . According to the identifier of the content control, the corresponding dynamic data is extracted from the data mapping table. According to the extracted dynamic data, the node content of the corresponding XML node is dynamically updated. The node attributes of the XML node inherit the format attributes of the content control. According to the updated XML node, the updated XML file is obtained. The updated XML file is rendered as a Word document through the specified engine. The generated target report is consistent with the format of the initial report template.
[0036] The present embodiment provides a method for generating a dynamic report, the method comprising: obtaining an initial report template, the initial report template comprising a fixed content area and a dynamic content area, wherein the dynamic content area is provided with a content control; utilizing a designated engine to parse the initial report template from a word document into an XML file, extracting XML nodes corresponding to the content controls in the XML file, and determining an identifier and format attributes of the content controls based on the extracted XML nodes, wherein the format attributes are used to characterize the data type, style rules, and size and position of the content controls; extracting corresponding dynamic data from a data mapping table based on the identifier, wherein the data mapping table is used to characterize the mapping relationship between the identifier and the corresponding dynamic data; updating the XML nodes based on the format attributes and the dynamic data to obtain an updated XML file; utilizing the designated engine to render the updated XML file into a target report consistent with the format of the initial report template, thereby solving the technical problem of low report generation efficiency in related technologies and achieving a what-you-see-is-what-you-get technical effect.
[0037] In some embodiments, updating the XML node based on the format attributes and the dynamic data includes: updating the node content of the XML node to the corresponding dynamic data; and the node attributes of the XML node inheriting the format attributes of the content control.
[0038] The XML node is updated based on the type of content control. For example, for a text control, dynamic data is replaced with the node content of the text control node. For a table control, the data list is traversed and the corresponding table row nodes are inserted. The number of table row nodes can be dynamically adjusted based on the data list. For an image control, the reference path of the generated temporary image is replaced with the node content of the image node. The node attributes of the XML node inherit the formatting properties of the content control, ensuring that the format of the generated target report remains consistent with that of the initial report template.
[0039] In some embodiments, the content control is a text control, and the method includes: extracting a text control node corresponding to the text control in the xml file; determining a first identifier and a first format attribute of the text control based on the text control node; extracting corresponding text data from the data mapping table based on the first identifier, and updating the first node content of the text control node to the text data; the first node attribute of the text control node inherits the first format attribute of the text control; using the specified engine, rendering the updated text control node as target text, and replacing the target text with the corresponding text control.
[0040] Among them, the text control node refers to the part of the XML file used to represent the text control, which contains the relevant information of the corresponding text control. Get the identifier and format attributes of the text control from the text control node. Use the identifier to extract the corresponding dynamic data and update the first node content of the corresponding text control. The first node attribute of the text control inherits the first format attribute. The first node attributes include font size, color, etc. With the help of the specified engine, the updated text control node is rendered into the target text for display. Replace the rendered target text with the position of the corresponding text control to complete the dynamic update of the text control.
[0041] In some embodiments, the content control is a table control, and the method includes: extracting a table row node corresponding to the table control in the xml file; determining a second identifier and a second format attribute of the table control based on the table row node; extracting a corresponding data list from the data mapping table based on the second identifier, and dynamically updating the number of nodes and the second node content of the table row node based on the data list; the second node attribute of the table row node inherits the second format attribute of the table control; using the specified engine, rendering the updated table row node as a target table, and replacing the target table with the corresponding table control.
[0042] Among them, the table row node refers to the part that represents the table control in the XML file. For the table control, the data mapping table Map<string,Object> The value (value) in the data list (list) is specified. The engine is specified to dynamically add corresponding table row nodes by traversing each element in the data list. Secondary node attributes include table border style, font, and other attributes. Using the specified engine, the updated table row nodes are rendered into a displayable target table. The rendered target table is then replaced in the corresponding table control's location, completing the dynamic update of the table control.
[0043] In some embodiments, the content control is a picture control, and the method includes: extracting a picture node corresponding to the picture control in the xml file; determining a third identifier and a third format attribute of the picture control based on the picture node; extracting corresponding chart data from the data mapping table based on the third identifier; configuring a velocity engine based on the chart data; generating a corresponding temporary picture using Echarts based on the configured velocity engine; updating the third node content of the picture node based on the temporary picture; the third node attribute of the picture node inherits the third format attribute of the picture control; using the specified engine, rendering the updated picture node as a target picture, and replacing the target picture with the corresponding picture control.
[0044] The image node refers to the portion of the XML file that represents an image control. The third identifier of the image control is obtained from the image control to uniquely identify it. The third format attribute of the image control defines the size, cropping method, and display mode of the image in the image control. The chart data corresponding to the third identifier is obtained from the data mapping table. The Velocity engine is configured based on the extracted chart data. The Velocity engine generates a template for Echarts rendering based on this chart data. Each Velocity template corresponds to a standard Echarts chart type, such as a line chart, scatter chart, or radar chart. Echarts generates a temporary image based on the configuration and chart data in the velocity template. Using the template generated by the Velocity engine and the Echarts chart library, this chart data is rendered as a temporary image. The generated temporary image is then updated to the node content of the corresponding image node, replacing the original node content. The node properties of the image node remain unchanged, inheriting the original third format attribute. Using the specified engine, the updated image node is rendered as the target image for display, and the target image is then replaced in the corresponding image control.
[0045] In some embodiments, when the data type is a plain text type, the content control is a text control, and the style rules include font size and font color; when the data type is a list type, the content control is a table control, and the style rules include table border style and font style; when the data type is a picture type, the content control is a picture control, and the style rules include picture size and cropping method.
[0046] If the data type of a content control is plain text, it is a text control used to display text content. The corresponding style rules include the font size and font color of the text content. If the data type of a content control is list, it is a table control used to display table content. The corresponding style rules include the merging method of cells in the table. If the data type of a content control is image, it is an image control used to display image content. The corresponding style rules include the background color and image size of the image.
[0047] In some embodiments, the identifier includes a variable symbol and a variable name, the data mapping table is a key-value pair data structure, the key-value pair data structure is used to represent the mapping relationship between keys and values, the identifier matches the key in the key-value pair data structure, and based on the identifier, the corresponding value in the key-value pair data structure is extracted, and the extracted value is used as the dynamic data.
[0048] The format of the identifier can be ${xxx}, which is a placeholder format, where ${} is a variable symbol and xxx is a variable name, which is used to uniquely identify the content control. In a key-value pair data structure, such as Map<string,Object> String represents the key, or identifier, and object represents the value, or dynamic data. The key-value data structure allows for quick retrieval of the corresponding value by key. The identifier must match the key in the key-value data structure to locate the corresponding dynamic data. Dynamic data is used to populate and update the content in content controls.
[0049] In some embodiments, the initial report template is in doc format or docx format, and the corresponding content control is set using a word development tool module.
[0050] Among them, doc format or docx format is a common word document format.
[0051] Accordingly, please refer to Figure 2 , Figure 2 Schematic diagram of the dynamic report generation system provided in the embodiment of this application. Figure 2 As shown, the dynamic report generation system includes: an acquisition module for acquiring an initial report template, the initial report template including a fixed content area and a dynamic content area, wherein the dynamic content area is provided with a content control; a parsing module for using a specified engine to parse the initial report template from a word document into an XML file, extracting XML nodes corresponding to the content controls in the XML file, and determining an identifier and format attributes of the content controls based on the extracted XML nodes, wherein the format attributes are used to characterize the data type, style rules, and size and position of the content controls; a rendering module for extracting corresponding dynamic data from a data mapping table based on the identifier, wherein the data mapping table is used to characterize the mapping relationship between the identifier and the corresponding dynamic data; updating the XML nodes based on the format attributes and the dynamic data to obtain the updated XML file; and using the specified engine, rendering the updated XML file into a target report consistent with the format of the initial report template.
[0052] The embodiments of the present application also provide the application of the above-mentioned dynamic report generation method in the field of financial quantitative analysis.
[0053] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0054] The dynamic report generation system in this embodiment is presented in the form of functional units, where the units refer to ASIC (Application Specific Integrated Circuit) circuits, processors and memories that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0055] See also Figure 3 , Figure 3 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 3 As shown, the computer device includes: one or more processors 10, memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components utilize different buses to communicate with each other and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in the memory or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Equally, multiple computer devices can be connected, and each device provides part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 3 A processor 10 is taken as an example.
[0056] The processor 10 may be a central processing unit, a network processor, or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic, or any combination thereof.
[0057] The memory 20 stores instructions that can be executed by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0058] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created based on the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0059] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0060] The computer device further includes a communication interface 30 for communicating with other devices or a communication network.
[0061] The embodiments of the present application also provide a computer-readable storage medium. The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.
[0062] An embodiment of the present application provides a computer program product, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform a method according to any embodiment of the present application.
[0063] The systems or modules described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0064] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0065] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0066] The present application is described with reference to the flowcharts and / or block diagrams of the methods, systems, and computer program products according to the embodiments of the present application. 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.
[0067] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device that implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0068] 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 the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0069] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of other identical elements in the process, method, commodity, or apparatus comprising the element.
[0070] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences from the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.
[0071] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.
[0072] Although the embodiments of the present application have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present application, and such modifications and variations shall fall within the scope defined by the appended claims.
Claims
1. A method for generating a dynamic report, characterized in that: The method comprises: Acquire an initial report template, the initial report template comprising a fixed content area and a dynamic content area, wherein the dynamic content area is provided with a content control; Parsing the initial report template from a Word document into an XML file using a designated engine, extracting XML nodes corresponding to the content control in the XML file, and determining an identifier and format attributes of the content control based on the extracted XML nodes, wherein the format attributes are used to characterize a data type, style rules, and size and position of the content control; Based on the identifier, the corresponding dynamic data is extracted from a data mapping table, wherein the data mapping table is used to characterize the mapping relationship between the identifier and the corresponding dynamic data; based on the format attributes and the dynamic data, the xml node is updated to obtain the updated xml file; and using the designated engine, the updated xml file is rendered into a target report consistent with the format of the initial report template.
2. The method according to claim 1, characterized in that Based on the format attribute and the dynamic data, updating the XML node includes: The node content of the XML node is updated to the corresponding dynamic data; the node attributes of the XML node inherit the format attributes of the content control.
3. The method according to claim 2, characterized in that The content control is a text control, and the method includes: Extracting a text control node corresponding to the text control in the XML file; and determining a first identifier and a first format attribute of the text control based on the text control node; Based on the first identifier, corresponding text data is extracted from the data mapping table, and the first node content of the text control node is updated to the text data; the first node attribute of the text control node inherits the first format attribute of the text control; The updated text control node is rendered as target text using the designated engine, and the target text is replaced into the corresponding text control.
4. The method according to claim 2, characterized in that The content control is a table control, and the method includes: Extracting a table row node corresponding to the table control in the XML file; and determining a second identifier and a second format attribute of the table control based on the table row node; Based on the second identifier, extracting a corresponding data list from the data mapping table, and dynamically updating the node quantity and second node content of the table row node based on the data list; the second node attribute of the table row node inherits the second format attribute of the table control; The designated engine is used to render the updated table row node into a target table, and the target table is replaced into the corresponding table control.
5. The method according to claim 2, characterized in that The content control is a picture control, and the method includes: Extracting a picture node corresponding to the picture control in the XML file; and determining a third identifier and a third format attribute of the picture control based on the picture node; Based on the third identifier, extract corresponding chart data from the data mapping table; based on the chart data, configure a velocity engine; based on the configured velocity engine, generate a corresponding temporary image using Echarts; based on the temporary image, update the third node content of the image node; the third node attribute of the image node inherits the third format attribute of the image control; The updated image node is rendered as a target image using the designated engine, and the target image is replaced in the corresponding image control.
6. The method according to claim 1, characterized in that When the data type is a plain text type, the content control is a text control, and the style rules include font size and font color; when the data type is a list type, the content control is a table control, and the style rules include table border style and font style; when the data type is a picture type, the content control is a picture control, and the style rules include picture size and cropping method.
7. The method according to claim 1, characterized in that The identifier includes a variable symbol and a variable name. The data mapping table is a key-value pair data structure. The key-value pair data structure is used to represent the mapping relationship between keys and values. The identifier matches the key in the key-value pair data structure. Based on the identifier, the corresponding value in the key-value pair data structure is extracted, and the extracted value is used as the dynamic data.
8. The method according to claim 1, characterized in that The initial report template is in doc format or docx format, and the corresponding content control is set using a word development tool module.
9. A dynamic report generation system, characterized in that: A method for generating a dynamic report according to any one of claims 1 to 8 can be implemented, wherein the system comprises: An acquisition module, configured to acquire an initial report template, wherein the initial report template includes a fixed content area and a dynamic content area, wherein the dynamic content area is provided with a content control; a parsing module, configured to parse the initial report template from a Word document into an XML file using a specified engine, extract XML nodes corresponding to the content control in the XML file, and determine an identifier and format attributes of the content control based on the extracted XML nodes, wherein the format attributes are used to characterize a data type, style rules, and size and position of the content control; A rendering module is used to extract corresponding dynamic data from a data mapping table based on the identifier, wherein the data mapping table is used to characterize the mapping relationship between the identifier and the corresponding dynamic data; based on the format attributes and the dynamic data, update the XML node to obtain the updated XML file; and use the specified engine to render the updated XML file into a target report consistent with the format of the initial report template.
10. Application of the method for generating a dynamic report according to any one of claims 1 to 8 in the field of financial quantitative analysis.
Citation Information
Cited By
Form generation method and system for authentication document
CN120911407A