Report generation method and device, equipment and storage medium
By generating HTML templates using a visual editor and converting them to DOCX format, combined with data processing, the limitations of existing technologies in report generation—namely, poor flexibility and operational difficulties—are resolved. This results in efficient, flexible, and easy-to-use report generation, improving report readability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 厦门天锐科技股份有限公司
- Filing Date
- 2026-01-14
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies for generating reports suffer from poor flexibility and difficulty in operation. Manual integration is labor-intensive and prone to errors, while custom code development is complex and costly to maintain. These limitations make it difficult to meet enterprises' needs for efficient, flexible, easy-to-operate, and highly readable report generation.
HTML template files are generated using a visual editor, converted to DOCX format, and then combined with data processing and template files to dynamically generate the final report. The system supports user-friendly template editing and data binding.
It lowers the barrier to template editing, improves the flexibility of data filling and report readability, and achieves efficient, flexible and easy-to-use report generation.
Smart Images

Figure CN121960423A_ABST
Abstract
Description
Report generation methods, apparatus, equipment and storage media Technical Field
[0001] This application relates to the field of computer software technology, and in particular to a report generation method, apparatus, device, and storage medium. Background Technology
[0002] With the development of the internet, enterprise informatization is accelerating. In areas such as enterprise operation analysis, data statistics, and business reporting, generating structured reports based on multi-dimensional business data is one of the core aspects of daily operations. These reports typically integrate various types of information, including text descriptions, tabular data, and statistical charts, and can intuitively reflect the status of business development, providing data support for decision-making.
[0003] Currently, the industry mainly generates the aforementioned business reports in two ways: one is by relying on traditional reporting systems to complete data statistics, followed by manual integration of report content by operations personnel. This requires manually capturing screenshots of report data, manually analyzing data patterns, and organizing and formatting the report text segment by segment. This not only consumes a lot of manpower but is also prone to data errors or formatting mistakes due to manual operation, resulting in extremely low report generation efficiency. The other way is to customize the report document by writing code. Although this method can achieve a certain degree of data and document integration, it also has significant technical drawbacks: on the one hand, code development requires professional programming skills, resulting in high development complexity, and ordinary operations personnel cannot participate in template adjustments or content modifications; on the other hand, the logic of the report document generated by code is strongly coupled with the code, and subsequent maintenance requires modifying the code and retesting, resulting in high maintenance costs. Furthermore, due to the fixed logic of the code, the content format of the report is monotonous and cannot flexibly adapt to the personalized report needs of different business scenarios.
[0004] In summary, existing technologies, whether through manual integration or custom code generation, suffer from poor flexibility and difficulty in operation, making it difficult to meet enterprises' core needs for efficient, flexible, easy-to-use, and highly readable report generation. Summary of the Invention
[0005] This application provides a report generation method, apparatus, device, and storage medium to solve the problems of poor flexibility and difficulty in operation that exist in the prior art when using manual or code-customized report generation methods.
[0006] Firstly, this application provides a report generation method, the method comprising:
[0007] In response to user template editing operations via the visual editor, generate HTML template files;
[0008] The HTML template file is converted to obtain a DOCX format template file with the same layout;
[0009] Obtain the data to be bound to the template file, perform data processing on the data, and store it in a specified format;
[0010] A final report is generated based on the processed data results and the template file.
[0011] In an optional embodiment of this application, generating an HTML template file in response to a user's template editing operation via a visual editor includes:
[0012] In response to the user's definition operation in the web-based visual editor, the user's defined styles and declarative tags are obtained, and an HTML template file is generated based on the defined styles and declarative tags;
[0013] The defined style is generated by the user through a visual editor by modifying formatting operations including at least font, color, size, and indentation.
[0014] The declarative tags are generated by the user by dragging and dropping components from the visual editor's component library into any position in the template file; the visual editor embeds a variety of commonly used component libraries, including but not limited to text, tables, and statistical charts; the components in the component library correspond to the declarative tags, and the declarative tags have specific tag formats.
[0015] In an optional embodiment of this application, converting the HTML template file to obtain a DOCX format template file with the same layout includes:
[0016] The HTML template file is converted into a DOCX format template file using a document conversion tool, while retaining the original layout and style attributes.
[0017] In an optional embodiment of this application, the step of obtaining the data to be bound to the template file, performing data processing on the data, and storing it in a specified format includes:
[0018] After obtaining the database query results, the data is stored in the corresponding format according to different data types and integrated into a data set, including: text data, stored as String type variables; tabular data, stored as arrays; and statistical chart data, stored as Base64 strings.
[0019] In an optional embodiment of this application, the step of obtaining the data to be bound to the template file, performing data processing on the data, and storing it in a specified format further includes:
[0020] Execute the data parsing script to parse the chart data and generate chart explanatory text.
[0021] In an optional embodiment of this application, the execution of the data parsing script to parse the chart data and generate chart explanatory text specifically includes:
[0022] For different business scenarios, statistical chart data is used as input to the data parsing script. The data parsing script executes trend analysis and extreme value identification algorithms to generate natural language descriptions that conform to the business scenario.
[0023] In an optional embodiment of this application, generating a final report based on the processed data results and the template file includes:
[0024] Scan the DOCX template file for declarative tags in the template;
[0025] For the declarative tags, match the data in the corresponding storage format;
[0026] The data is rendered to the corresponding position of the declarative tag in the DOCX template file, and the final report is obtained and output after rendering is completed.
[0027] In an optional embodiment of this application, matching the data in the corresponding storage format for the declarative tag includes:
[0028] The types of the declarative tags are analyzed, including the identifying features of text tags, table tags, and image tags;
[0029] Data can be matched to the corresponding format based on the tag type, including String text, array-type table data, and Base64 encoded image strings.
[0030] Secondly, this application provides a report generation apparatus, the apparatus comprising:
[0031] The HTML template file generation module is used to generate HTML template files in response to user template editing operations through the visual editor;
[0032] The conversion module is used to convert the HTML template file to obtain a DOCX format template file with the same layout.
[0033] The data acquisition module is used to acquire the data to be bound to the template file, perform data processing on the data, and store it in a specified format;
[0034] The report generation module is used to generate a final report based on the processed data results and the template file.
[0035] Thirdly, this application provides a report generation device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the processor is configured to generate an HTML template file in response to a user's template editing operation via a visual editor;
[0036] The HTML template file is converted to obtain a DOCX format template file with the same layout;
[0037] Obtain the data to be bound to the template file, perform data processing on the data, and store it in a specified format;
[0038] A final report is generated based on the processed data results and the template file.
[0039] Fourthly, this application also provides a computer storage medium storing computer-executable instructions for executing the report generation method described in any of the preceding claims.
[0040] Compared with the prior art, the technical solution provided in this application has the following advantages: The report generation method provided in this application first responds to the user's template editing operation through a visual editor to generate an HTML template file; the HTML template file is converted to obtain a DOCX format template file with the same layout; data to be bound to the DOCX format template file is obtained, data processing is performed on the obtained data and stored in a specified format; the final report is generated based on the processed data result and the DOCX format template file. Furthermore, in this embodiment, the user can edit their desired template through a visual editor, and then the system automatically obtains data and generates the final report according to the template. Compared with the existing methods of manually integrating and writing reports and generating customized reports by code, this method has more flexible, efficient, convenient, and widely applicable technical effects. Attached Figure Description
[0041] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0044] Figure 1 is a flowchart illustrating a report generation method provided in an embodiment of this application;
[0045] Figure 2 is a schematic diagram illustrating the principle of generating a final report according to an embodiment of this application;
[0046] Figure 3 is a schematic diagram of generating a final report based on the processed data results and the template file provided in an embodiment of this application;
[0047] Figure 4 is a schematic diagram of a report generation device provided in an embodiment of this application;
[0048] Figure 5 is a structural schematic diagram of a report generation device provided in an embodiment of this application. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0050] The following disclosure provides numerous different embodiments or examples for implementing various structures of the invention. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of the invention. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0051] Existing reporting systems cannot integrate user-relevant data into a single report, requiring operators to manually screenshot, analyze, and synthesize data. Generating reports directly using code is complex, difficult to maintain, and results in relatively simple content. Therefore, there is an urgent need for a report generation technology that lowers the barrier to template editing, improves data entry flexibility, and enhances report readability to address these shortcomings. Based on this, this application provides a report generation method, apparatus, device, and storage medium.
[0052] The technical solution of this application will be described in detail below through specific embodiments.
[0053] Figure 1 is a flowchart illustrating a report generation method provided in an embodiment of this application; referring to Figure 1, the method includes the following steps S10-S40:
[0054] S10. Responding to the user's template editing operation through the visual editor, generate an HTML template file.
[0055] In this embodiment, a visual editor interface is provided to the user in the form of a webpage. Through this visual editor, the user can edit the HTML template file of the final report just like using an office tool.
[0056] In an optional embodiment of this application, step S10 specifically includes the following step A10:
[0057] Step A10: In response to the user's definition operation in the visual editor on the web page, obtain the user's defined style and declarative tags, and generate an HTML template file based on the defined style and declarative tags.
[0058] The aforementioned style definition is generated by the user through a visual editor, modifying formatting operations including at least font, color, size, and indentation.
[0059] The aforementioned declarative tags are generated by the user by dragging and dropping components from the visual editor's component library into any location within the template file; the visual editor embeds various commonly used component libraries, including but not limited to text, tables, and statistical charts; the components in the component library correspond to declarative tags, and the declarative tags have specific tag formats.
[0060] In this embodiment, users can easily define styles, modify fonts, colors, sizes, and set indentation using a visual editor, just like editing a Word document in Office.
[0061] In the process of defining declarative tags, the visual editor has a variety of commonly used component libraries that cover a variety of declarative tags, including text, tables, charts and other types. These can be embedded into the template file by dragging and dropping to meet diverse template design needs.
[0062] For example, all labels begin with the symbol "{{" and end with the symbol "}}". Labels can appear anywhere, including headers, footers, inside tables, text boxes, etc.
[0063] For example:
[0064] 1. Text, such as: "As of the time the report was generated, The department deployed a total of Terminal equipment.
[0065] 2. The table is shown below. This is the declarative tag for the form:
[0066]
[0067] 3. Images. Image tags begin with the symbol "@", such as: .
[0068] S20. Convert the HTML template file to obtain a DOCX format template file with the same layout.
[0069] Figure 2 is a schematic diagram illustrating the principle of generating a final report according to an embodiment of this application; referring to Figure 2, in a specific embodiment of this application, step S20 specifically includes the following step B10:
[0070] Step B10: Convert the HTML template file into a DOCX format template file using a document conversion tool, while preserving the original layout and style attributes.
[0071] In this embodiment, an HTML template is converted into a DOCX format template file using a document conversion tool, while retaining the original layout (such as indentation, alignment, pagination, etc.) and style attributes (font, color, size, etc.), thereby ensuring the consistency between the DOCX format template file and the aforementioned HTML template file.
[0072] S30. Obtain the data to be bound to the template file, perform data processing on the data, and store it in a specified format.
[0073] In this embodiment, for the data that needs to be filled in the DOCX format template file obtained above, the user triggers a query from the database to obtain the data results. The system stores different types of data in the corresponding data format to obtain a data set corresponding to the document template file, so that it can be used when generating documents later.
[0074] In a specific embodiment of this application, step S30 specifically includes the following steps C10-C20:
[0075] Step C10: After the user obtains the database query results, store the data in the corresponding format according to different data types, and integrate them into a data set, including: text data, stored as String type variables; table data, stored as arrays; and statistical chart data, stored as Base64 strings.
[0076] Furthermore, in one specific embodiment, after obtaining the database query results, the data is stored in corresponding formats according to different data types and integrated into a data set. These different data types can be:
[0077] Text data is stored directly as a String type variable;
[0078] The tabular data is stored in array form, which contains multiple data groups containing data such as department name, total number of files, and number of files created.
[0079] The statistical chart data is used to generate PNG format images through visualization tools such as JFreeChart, and then encoded as Base64 strings.
[0080] Step C20: Execute the data parsing script to parse the chart data and generate chart explanatory text.
[0081] In this embodiment, statistical chart data is used as input to the data parsing script for different business scenarios. The data parsing script executes algorithms for trend analysis and extreme value identification to generate natural language descriptions that conform to the business scenarios.
[0082] Specifically, the input, processing, and output process of the above parsing script is as follows:
[0083] Input: The original data set for the statistical chart;
[0084] Processing: Execute algorithms such as trend analysis (month-on-month / year-on-year calculation) and extreme value identification;
[0085] Output: Generate natural language descriptions that match the business scenario, such as "March sales reached a peak of 1.2 million yuan, a month-on-month increase of 25%".
[0086] S40. Generate a final report based on the processed data results and the template file.
[0087] In a specific embodiment of this application, referring to FIG3, step S40 above, which involves generating a final report based on the processed data results and the template file, specifically includes the following steps S401-S403:
[0088] S401. Scan the declarative tags in the DOCX template file.
[0089] S402. For the declarative tag, match the data in the corresponding storage format.
[0090] The types of the declarative tags are analyzed, including the identifying features of text tags, table tags, and image tags;
[0091] Data can be matched to the corresponding format based on the tag type, including String text, array-type table data, and Base64 encoded image strings.
[0092] S403. Render the data to the corresponding position of the declarative tag in the DOCX template file, and obtain and output the final report after rendering is completed.
[0093] In a further specific embodiment, the above-mentioned report generation stage includes the following process:
[0094] Tag parsing: Use a template engine to scan for declarative tags in the DOCX template, such as those mentioned above. .
[0095] Data binding: Matching the data set generated during the data processing stage with the scanned declarative tags to complete the dynamic data binding.
[0096] Report generation: The template engine rendering function is invoked to fill the bound data into the corresponding positions in the template, thus generating a DOCX format report.
[0097] In summary, the report generation method provided by the above embodiments of this application has the following positive effects:
[0098] Lowering the barrier to template editing: User-friendly operation through a visual editor, easy template file creation by dragging and dropping components, and user-defined templates for greater diversity.
[0099] Enhance data population flexibility: Implement dynamic data binding by combining with a template engine.
[0100] Improve report readability: Use the visual editor to quickly define templates according to your own needs and integrate the data you are interested in into a single report; execute scripts to dynamically analyze chart data (such as trends and extreme values) and generate natural language descriptions, thereby dynamically generating chart explanatory text and improving report readability.
[0101] Figure 4 is a schematic diagram of a report generation device provided in an embodiment of this application; referring to Figure 4, the report generation device includes:
[0102] HTML template file generation module 301 is used to generate HTML template files in response to user template editing operations through a visual editor;
[0103] The conversion module 302 is used to convert the HTML template file to obtain a DOCX format template file with the same layout.
[0104] The data acquisition module 303 is used to acquire data to be bound to the template file, perform data processing on the data, and store it in a specified format;
[0105] The report generation module 304 is used to generate a final report based on the processed data results and the template file.
[0106] It should be noted that the specific implementation of the device embodiments of this application can be found in the detailed step descriptions of the above method embodiments, and will not be repeated here.
[0107] As shown in Figure 5, this application embodiment provides a report generation device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0108] Memory 113 is used to store computer programs;
[0109] In one embodiment of this application, when the processor 111 executes the program stored in the memory 113, it implements the software license control method provided in any of the foregoing method embodiments, including: generating an HTML template file in response to a user's template editing operation through a visual editor;
[0110] The HTML template file is converted to obtain a DOCX format template file with the same layout;
[0111] Obtain the data to be bound to the template file, perform data processing on the data, and store it in a specified format;
[0112] A final report is generated based on the processed data results and the template file.
[0113] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the report generation method provided in any of the foregoing method embodiments.
[0114] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0115] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0116] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.
[0117] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A report generation method, characterized in that, The method includes: generating an HTML template file in response to a user's template editing operation through a visual editor; converting the HTML template file to obtain a DOCX format template file with the same layout; acquiring data to be bound to the template file, performing data processing on the data and storing it in a specified format; and generating a final report based on the processed data results and the template file.
2. The method according to claim 1, characterized in that, The step of generating an HTML template file in response to a user's template editing operation in a visual editor includes: responding to a user's definition operation in a web-based visual editor, obtaining the user's defined styles and declarative tags, and generating an HTML template file based on the defined styles and declarative tags; wherein, the defined styles are generated by the user modifying formatting operations, including at least font, color, size, and indentation, through the visual editor; the declarative tags are generated by the user embedding components from the visual editor's component library into any position in the template file by dragging and dropping; wherein, the visual editor embeds various commonly used component libraries, including but not limited to text, tables, and statistical charts; the components in the component library correspond to declarative tags, and the declarative tags have specific tag formats.
3. The method according to claim 1, characterized in that, The step of converting the HTML template file to obtain a DOCX format template file with the same layout includes: converting the HTML template file to a DOCX format template file using a document conversion tool, while retaining the original layout and style attributes.
4. The method according to claim 1, characterized in that, The process of obtaining the data to be bound to the template file, performing data processing on the data, and storing it in a specified format includes: after the user obtains the database query results, storing the data in the corresponding format according to different data types, and integrating them into a data set, including: text data, stored as String type variables; table data, stored as arrays; and statistical chart data, stored as Base64 strings.
5. The method according to claim 4, characterized in that, The step of obtaining the data to be bound to the template file, performing data processing on the data and storing it in a specified format also includes: executing a data parsing script, parsing the chart data, and generating chart explanatory text.
6. The method according to claim 5, characterized in that, The execution of the data parsing script, which parses chart data and generates chart explanatory text, specifically includes: for different business scenarios, calling statistical chart data as input to the data parsing script, executing trend analysis and extreme value identification algorithms through the data parsing script, and generating natural language descriptions that conform to the business scenario.
7. The method according to any one of claims 4 to 6, characterized in that, The process of generating a final report based on the processed data results and the template file includes: scanning declarative tags in the DOCX template file; matching data in the corresponding storage format for the declarative tags; rendering the data to the corresponding position of the declarative tags in the DOCX template file; and obtaining and outputting the final report after rendering is complete.
8. The method according to claim 7, characterized in that, The step of matching data in the corresponding storage format for the declarative tags includes: parsing the type of the declarative tags, including the identifier features of text tags, table tags, and image tags; and matching data in the corresponding format according to the tag type, including String type text, array type table data, and Base64 encoded image strings.
9. A report generation device, characterized in that, include: The HTML template file generation module is used to generate HTML template files in response to user template editing operations through the visual editor; The conversion module is used to convert the HTML template file to obtain a DOCX format template file with the same layout. The data acquisition module is used to acquire the data to be bound to the template file, perform data processing on the data, and store it in a specified format; The report generation module is used to generate a final report based on the processed data results and the template file.
10. A report generation device, characterized in that, include: At least one communication interface; At least one bus connected to the at least one communication interface; At least one processor connected to the at least one bus; At least one memory connected to the at least one bus, wherein the processor is configured to execute the report generation method according to any one of claims 1-8.