Excel file dynamic generation method and device based on front-end configuration
Through front-end configuration and XML template conversion, Excel files are generated dynamically, solving the problems of low generation efficiency and maintenance difficulties in the existing technology, and achieving efficient and flexible Excel file generation.
Patent Information
- Application Number
- CN202510745251.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-07-04
AI Technical Summary
The prior art is inefficient in generating Excel files, has difficulty in maintaining and has high technical requirements for developers, making it difficult to quickly respond to dynamic business needs.
Receive user information through the front-end configured Excel template custom interface, convert it into a structured XML template, and obtain fill data from multiple data sources to dynamically generate Excel tables.
It improves the efficiency, accuracy and maintainability of Excel table generation, lowers the technical threshold, and meets complex business needs.
Smart Images

Figure CN120257952A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer software technology, and more particularly, to a method and apparatus for dynamically generating Excel files based on front-end configuration, as well as a computer-readable storage medium storing a computer program. Background Art
[0002] With the growing demand of modern enterprises for data analysis and decision-making support, software systems need to provide more flexible and intuitive statistical analysis results to users when processing and presenting large amounts of data. As a widely used data presentation tool, Excel's flexibility and visualization effects make it the preferred format for many software systems to output data. Especially in fields such as report generation, business analysis, and financial management, users usually need to generate clear Excel tables from complex data sets for further analysis and decision-making.
[0003] However, in the traditional programming implementation of Excel generation, developers often need to perform a large amount of manual coding to define the format, content, and structure of Excel. This approach is not only time-consuming but also has a high maintenance cost as the system complexity increases. Especially when faced with dynamically changing business requirements, the traditional manual coding solution is difficult to quickly respond to the changes in requirements and is prone to introducing errors.
[0004] To overcome these problems, there have been various technical methods in the industry trying to improve the efficiency and flexibility of generating Excel files. For example, based on template files, developers can pre-define the structure and format of Excel, and the data filling logic is dynamically implemented by the program. This approach can greatly reduce the amount of coding, but there are still problems with the maintenance and modification of templates. By defining the structure and rules of Excel tables through configuration files, the system automatically generates Excel according to the configuration files. This approach improves flexibility through the separation of configuration and data, but when business requirements are complex, a large amount of effort is still required for the maintenance of the configuration files. Some low-code or no-code development platforms provide a visual operation interface for Excel table generation, which reduces the technical threshold and enables non-developers to create and modify Excel reports. However, when it comes to highly customized requirements, the flexibility and scalability of the platform are often limited.
[0005] Therefore, there is a need for a more efficient, flexible, and easy-to-maintain solution that can automatically generate Excel files with complex structures while providing higher customizability to meet continuously changing business requirements. Summary of the Invention
[0006] The embodiments described in this document provide a method, apparatus, and computer-readable storage medium storing a computer program for dynamically generating an Excel file based on front-end configuration. By configuring the Excel template header on the front-end page and combining the XML format and multiple data sources, an Excel file is dynamically generated, aiming to solve the problems of low generation efficiency, difficult maintenance, and high technical requirements for developers in the prior art.
[0007] According to a first aspect of the present disclosure, there is provided a method for dynamically generating an Excel file based on front-end configuration, including: receiving Excel template configuration information defined by a user on an Excel template customization interface, where the Excel template configuration information includes the attributes and methods of the template; converting the Excel template configuration information into a structured XML template, where the structure of the XML template corresponds to that of the Excel template; obtaining the filling data required for the Excel table from a database, an independent data set, or a data interface; parsing the XML template to extract the attributes and methods of the template, and dynamically generating an Excel table based on the extracted information and the filling data.
[0008] In some embodiments of the present disclosure, receiving Excel template configuration information defined by a user on an Excel template customization interface, where the Excel template configuration information includes the attributes and methods of the template includes: receiving the header fields, types, and default values, as well as the method names, parameter lists, and return types defined by the user for a preset template or a custom template on the Excel template configuration interface; receiving the storage path of the template defined by the user, and saving the configured template according to the storage path.
[0009] In some embodiments of the present disclosure, receiving Excel template configuration information defined by a user on an Excel template customization interface, where the Excel template configuration information includes the attributes and methods of the template further includes: receiving the update and maintenance information of the same Excel template by multiple users; sharing the configured Excel template with users within the Excel template configuration permission.
[0010] In some embodiments of the present disclosure, converting the Excel template configuration information into a structured XML template, where the structure of the XML template corresponds to that of the Excel template includes: using a preset conversion tool to parse the Excel template, and extracting the header fields, field types, method definitions, styles, and format information from the Excel template; defining the XML template structure so that the XML template structure corresponds one-to-one to the information extracted from the Excel template; and converting each attribute, field, and rule in the Excel template configuration into the XML format one by one and mapping them to the XML template structure.
[0011] In some embodiments of the present disclosure, obtaining the filling data required for the Excel table from a database, an independent data set, or a data interface includes: if the existing data interface of the system can provide the required data, using the data interface to obtain the Excel filling data; or directly obtaining the Excel filling data from a data set independent of the database; or obtaining the Excel filling data according to the return result of an SQL query statement; configuring the mapping relationship between the data source and the Excel template fields so as to fill the data into the Excel table according to the mapping relationship.
[0012] In some embodiments of the present disclosure, parsing the XML template to extract the attributes and methods of the template and dynamically generating an Excel table according to the extracted information and the filling data includes: parsing the XML template to obtain the Excel template definition information, where the Excel template definition information includes the header fields of the Excel and the corresponding data sources, field attributes, method definitions, data formats, and rules; performing data cleaning on the data obtained from the data source and performing corresponding format conversions on the data according to the field attributes, and filling the converted data into the corresponding columns of the Excel; dynamically generating an Excel table according to the Excel template definition information and the filling data.
[0013] In some embodiments of the present disclosure, dynamically generating an Excel table according to the Excel template definition information and the filling data includes: generating an Excel header based on the parsed header fields; for fields involving calculations or conversions, dynamically applying relevant functions according to the method definitions; if the XML template contains style and format information, applying it to the cells of the Excel table according to the description of the XML template, and merging the cells in the Excel according to the predefined rules.
[0014] In some embodiments of the present disclosure, the method further includes: creating an Excel file using openpyxl according to the parsed and processed data, and saving the generated Excel file as a file stream in memory so as to be directly available for users to download in a Web application.
[0015] According to a second aspect of the present disclosure, there is provided an Excel file dynamic generation device based on front-end configuration. The device includes at least one processor; and at least one memory storing a computer program. When the computer program is executed by the at least one processor, the device is caused to: receive Excel template configuration information defined by a user on an Excel template customization interface, where the Excel template configuration information includes the attributes and methods of the template; convert the Excel template configuration information into a structured XML template, the structure of the XML template corresponding to the Excel template; obtain the filling data required for the Excel table from a database, an independent data set, or a data interface; parse the XML template to extract the attributes and methods of the template, and dynamically generate an Excel table according to the extracted information and the filling data.
[0016] According to a third aspect of the present disclosure, there is provided a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the method for dynamically generating an Excel file based on front-end configuration according to the first aspect of the present disclosure.
[0017] According to the method and device for dynamically generating an Excel file based on front-end configuration provided by the embodiments of the present disclosure, a user can dynamically customize different Excel templates through a graphical interface according to actual needs, without having to deeply understand the internal structure of Excel or write complex code. By converting the Excel template into a structured XML template, it is possible to automatically generate an Excel file, reducing human errors and cumbersome operations. During the generation process, by automatically filling in data and dynamically generating an Excel file that conforms to a preset format according to the template configuration, the efficiency, accuracy, and maintainability of Excel table generation are greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the accompanying drawings of the embodiments will be briefly described below. It should be understood that the following described drawings only relate to some embodiments of the present disclosure and do not limit the present disclosure, where: Figure 1 is an exemplary flowchart of the method for dynamically generating an Excel file based on front-end configuration according to an embodiment of the present disclosure; Figure 2 is a schematic diagram of an Excel template configuration interface according to an embodiment of the present disclosure; Figure 3 is a schematic block diagram of the Excel file dynamic generation device based on front-end configuration according to an embodiment of the present disclosure.
[0019] It should be noted that the elements in the drawings are schematic and not drawn to scale. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the following will clearly and completely describe the technical solutions of the embodiments of the present disclosure with reference to the accompanying drawings. Apparently, the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments obtained by those skilled in the art based on the described embodiments of the present disclosure without creative efforts also fall within the scope of protection of the present disclosure.
[0021] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those skilled in the art to which the subject matter of the present disclosure belongs. Further, it will be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the specification and the relevant art, and will not be interpreted in an idealized or overly formal form unless clearly defined otherwise herein. Additionally, terms such as "first" and "second" are only used to distinguish one component (or a part of a component) from another component (or another part of a component).
[0022] The embodiments of the present disclosure provide an efficient and configurable method for processing and exporting Excel spreadsheet data through the design and management of Excel templates in combination with flexible data integration methods. Users can customize Excel templates, process various data sources, and finally generate Excel files that meet requirements, which not only simplifies the workload of developers but also improves the operation convenience and flexibility of users, and is applicable to various data reporting and analysis scenarios.
[0023] Figure 1 is an exemplary flowchart of a method for dynamically generating an Excel file based on front-end configuration according to an embodiment of the present disclosure. At Figure 1 block S102 of the method 100 shown, receive the Excel template configuration information defined by the user on the Excel template customization interface, where the Excel template configuration information includes the attributes and methods of the template.
[0024] In some embodiments of the present disclosure, a graphical Excel template customization interface is provided for users. Users can create and edit the required Excel templates through simple interaction methods such as clicking, filling, and selecting operations. Users do not need to write any code and only need to define configuration information such as the attributes and methods of the Excel template through tables and drop-down menus.
[0025] First, receive the header fields, types, default values, method names, parameter lists, and return types defined by the user for the preset template or custom template in the Excel template configuration interface. The user can select a preset template or a custom template, name and identify the Excel template. For example, naming it project information, contract information, annual plan details, etc., which helps to distinguish and manage among multiple templates. The user can select or define the type of the template, such as "data summary table", "financial statement", "sales statistics table", etc., to determine the application scenario and function of the template.
[0026] Figure 2 is a schematic diagram of the Excel template configuration interface according to an embodiment of the present disclosure. Refer to Figure 2 As shown, after the user enters the header information configuration interface, the user is prompted to set the column name, node type, depth, sorting, whether to disable, etc. of the Excel table. The user can add, modify, or delete columns. The root node represents the top layer of the entire data. For example, "budget information", "contract information", "annual execution projects", etc. The leaf node is the final data item. For example, "serial number", "plan category", "remark", etc. Whether to disable is used to identify whether this item is disabled, and through this identifier, it is determined which nodes or data items can be excluded or disabled when exporting to Excel. Some cells in the template may require default values. By presetting the default data of certain fields (such as zero, null value, or a certain common value), subsequent manual input is reduced. Receive the method name, parameter list, and return type defined by the user. Specifically, each header field will be associated with a specific data field to describe the meaning of the data. The user can customize the name of the method, which usually corresponds to the formula or custom function name that needs to be used in Excel. Define the input parameters for each method, specifying the name, type (such as integer, string, etc.) of each parameter, and whether it is a required item. Define the data type returned after the method is executed, which may be a number, text, date, boolean value, etc.
[0027] The visual styles such as the display format, width, font, color, border, etc. of the field can also be set, and a short description text can be added to the template to facilitate team members to understand the purpose and structure of the template. For cases where the result needs to be dynamically adjusted according to the user input, the user is allowed to define multiple calculation methods (such as conditional judgment, summation, average value, etc.). To avoid incorrect input, the user can define data verification rules. For example, set that only numbers within a specific range can be entered in a certain column, or ensure that a certain field must be in date format.
[0028] Finally, receive the storage path of the user-defined template and save the configured template according to the storage path. The user can view the preview effect of the Excel template in real time, and the preview shows the data formats, fields, methods, and formulas of each column in the template to ensure that the template meets the expected structure and functions. Receive the storage path of the template configured by the user in the system settings menu. Once the template is set up, the system will save the template file according to this path to ensure that the template file can be easily found for subsequent use. The storage path can be a local directory, cloud storage, or a specific location in a database.
[0029] According to an embodiment of the present disclosure, multiple users can jointly edit and maintain the same template. That is, team members can update and maintain the template simultaneously, and the system synchronizes all changes in real time. When a team member modifies the template, other members can immediately see the modification results, avoiding the version inconsistency problem in traditional single-user operations and improving work efficiency and the smoothness of collaborative cooperation. Share the configured Excel template with users within the Excel template configuration permissions to facilitate team members or different departments to apply the template in different scenarios and enhance the reusability of the template.
[0030] Subsequently, at Figure 1 box S104, convert the Excel template configuration information into a structured XML template, and the structure of the XML template corresponds to that of the Excel template.
[0031] As a lightweight and extensible markup language, XML can clearly record the definitions, attributes of all fields in the template, and how to generate an Excel table based on the data. The structure of the XML template corresponds one-to-one with that of the Excel template to ensure that each element in Excel can be accurately mapped into the XML format.
[0032] According to an embodiment of the present disclosure, use a preset conversion tool to parse the Excel template and extract the header fields, field types, method definitions, styles, and format information from the Excel template. Open-source libraries or tools can be used to parse Excel files, such as Apache POI (Java), openpyxl (Python), or xlrd (Python), to extract field information from each column in Excel, including field names, data types, etc. Determine the structure of the template, for example, each column corresponds to a field and each row corresponds to a data item. If the Excel template uses styles (such as fonts, colors, borders, alignment methods, etc.), these styles also need to be extracted.
[0033] Define the XML template structure so that the XML template structure corresponds one-to-one with the information extracted from the Excel template. Convert each attribute, field, and rule in the Excel template configuration into XML format one by one and map them to the XML template structure. For example, each column (header field) in Excel is defined as a <column>The elements; the attributes of the header (such as column names, data types) are defined in XML as this <column>The attributes of elements; the definition of rows, the data filling rules, etc. can be specified in XML through <row> 、 <cell>It is represented by elements such as ; style configurations (such as fonts, colors, etc.) can be identified through specific attributes in XML. The XML template can be docked with other business systems or databases to dynamically generate data that matches the Excel template and be processed according to the rules defined in XML. After completing the template conversion, the tool outputs and saves the generated XML template, and the user can save the XML template locally or upload it to the server.
[0034] Then at Figure 1 in the box S106, obtain the filling data required for the Excel table from the database, independent data set, or data interface.
[0035] If the existing data interface of the system can provide the required data, use the data interface to obtain the Excel filling data; or directly obtain the Excel filling data from a data set independent of the database; or obtain the Excel filling data based on the return result of the SQL query statement. Configure the mapping relationship between the data source and the Excel template fields so that the data can be filled into the Excel table according to the mapping relationship.
[0036] Specifically, the integration methods of the data source are divided into three categories. One is to obtain data using database SQL statements. Query the data in the database through SQL statements to flexibly obtain the data set to be exported. For example, if you want to obtain customer names and order data from the customer information table, you can use the following SQL query statement: sql SELECT customer_name, order_date, order_amount FROM customers WHERE order_date BETWEEN '2024-01-01' AND '2024-12-31'; The SQL statement can be modified according to actual needs, such as adding fields, filtering conditions, sorting, etc. After executing the SQL query and obtaining the result, developers can use programming languages (such as Python, Java) to export the query result to the Excel format. The flexibility of the SQL statement enables users to dynamically adjust the query conditions according to business requirements, thereby generating Excel files with different structures. Users do not need to re-develop the application. They only need to adjust the SQL statement according to needs to generate the required data, which is suitable for scenarios where a large amount of data needs to be extracted from an existing database.
[0037] One way is to directly use a dataset. Such a dataset is independent of the database and can be a file in CSV, JSON, or other formats. It has strong portability and flexibility and is suitable for scenarios with relatively small data volumes or applications that do not rely on a database. Another way is to obtain data through existing application programming interfaces (APIs). This can flexibly extract datasets from already developed applications, integrate with existing systems without the need for redevelopment, and is suitable for scenarios of docking with existing applications. The data interfaces can be RESTful APIs, SOAP web services, etc., which allow obtaining the required data from external applications and generating Excel files.
[0038] Through the above three methods, data from different sources can be efficiently integrated into Excel to generate data reports and analysis tables that meet the requirements.
[0039] Finally, in box S108, the XML template is parsed to extract the attributes and methods of the template, and an Excel table is dynamically generated based on the extracted information and the filled data.
[0040] According to an embodiment of the present disclosure, an XML template can be read and parsed to obtain Excel template definition information. The Excel template definition information includes the header fields of Excel and the corresponding data sources, field attributes, method definitions, data formats, and rules. After parsing the XML template and extracting the field definitions, the data obtained from the database, data interface, or dataset is cleaned and format-converted. For example, duplicate data is removed, missing values are filled, data format conversion (such as date format conversion, number formatting, etc.), and data type conversion (such as string conversion to integer, floating data conversion to fixed format, etc.) are performed. Based on the Excel template definition information and the filled data, an Excel table is dynamically generated from the cleaned data. This includes: generating an Excel header based on the parsed header fields; for fields involving calculations or conversions, relevant functions are dynamically applied according to the method definitions; if the XML template contains style and format information, it is applied to the cells of the Excel table according to the description of the XML template, and cells in the Excel are merged according to predefined rules.
[0041] When generating the Excel file, an Excel file can be created using openpyxl according to the template selected by the user and the parsed and processed data, and the generated Excel file is saved as a file stream in memory for direct download by the user in the web application.
[0042] Through the combination of the XML template and the data source, the system can flexibly generate Excel files that meet business requirements, including supporting operations such as complex header design, data merging, and format adjustment.
[0043] Figure 3 is a schematic block diagram of an Excel file dynamic generation device based on front - end configuration according to an embodiment of the present disclosure. As Figure 3 shown, the device 300 may include a processor 310 and a memory 320 storing a computer program. When the computer program is executed by the processor 310, the device 300 can execute the steps of the method as Figure 1 shown. In one example, the device 300 can receive Excel template configuration information defined by a user on an Excel template customization interface, where the Excel template configuration information includes the attributes and methods of the template; convert the Excel template configuration information into a structured XML template, and the structure of the XML template corresponds to that of the Excel template; obtain the filling data required for the Excel table from a database, an independent data set, or a data interface; parse the XML template to extract the attributes and methods of the template, and dynamically generate an Excel table based on the extracted information and the filling data.
[0044] In some embodiments of the present disclosure, the device 300 can receive the header fields, types, default values, method names, parameter lists, and return types defined by the user for a preset template or a custom template on the Excel template configuration interface; receive the storage path of the template defined by the user, and save the configured template according to the storage path.
[0045] In some embodiments of the present disclosure, the device 300 can receive update and maintenance information of multiple users for the same Excel template; share the configured Excel template with users within the Excel template configuration permissions.
[0046] In some embodiments of the present disclosure, the device 300 can use a preset conversion tool to parse the Excel template, extract the header fields, field types, method definitions, styles, and format information from the Excel template; define the XML template structure so that the XML template structure corresponds one - to - one with the information extracted from the Excel template; and convert each attribute, field, and rule in the Excel template configuration into XML format one by one and map them to the XML template structure.
[0047] In some embodiments of the present disclosure, the device 300 can parse the XML template to obtain Excel template definition information, where the Excel template definition information includes the header fields of Excel and the corresponding data sources, field attributes, method definitions, data formats, and rules; perform data cleaning on the data obtained from the data source, perform corresponding format conversions on the data according to the field attributes, and fill the converted data into the corresponding columns of Excel; and dynamically generate an Excel table based on the Excel template definition information and the filling data.
[0048] In an embodiment of the present disclosure, the processor 310 may be, for example, a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a processor based on a multi-core processor architecture, etc. The memory 320 may be any type of memory implemented using data storage technology, including but not limited to random access memory, read-only memory, semiconductor-based memory, flash memory, disk memory, etc.
[0049] In addition, in an embodiment of the present disclosure, the device 300 may also include an input device 330, such as a keyboard, a mouse, etc., for inputting Excel template configuration information. Additionally, the device 300 may further include an output device 340, such as a display, etc., for displaying the generated Excel file.
[0050] In other embodiments of the present disclosure, a computer-readable storage medium storing a computer program is also provided, wherein the computer program, when executed by a processor, can implement the steps of the method for dynamically generating an Excel file based on front-end configuration as Figure 1 shown.
[0051] In summary, according to the method and device for dynamically generating an Excel file based on front-end configuration in the embodiments of the present disclosure, by allowing a user to define template configuration information on a front-end Excel template customization interface and convert it into a structured XML template, manual operations can be effectively reduced, complex programming processes can be avoided, and the technical thresholds for development and maintenance can be lowered. After storing the definition information of the Excel template as an XML template, by parsing the XML template and combining it with populated data, the system can dynamically generate an Excel table that conforms to a preset format, greatly improving the efficiency, accuracy, and maintainability of Excel table generation. Through the design of separating the template and data, the scalability and flexibility of the system are greatly enhanced, and it can meet increasingly complex business requirements.
[0052] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of devices and methods according to multiple embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of an instruction, and the module, program segment, or part of an instruction contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0053] Unless the context clearly indicates otherwise, the singular forms of words used in this specification and the appended claims include the plural, and vice versa. Thus, when referring to the singular, it generally includes the plural of the corresponding term. Similarly, the words "comprising" and "including" will be interpreted as inclusive rather than exclusive. Likewise, the term "including" and "or" should be interpreted as inclusive, unless such an interpretation is explicitly prohibited herein. Where the term "exemplary" is used in this specification, particularly when it is located after a list of terms, "exemplary" is merely illustrative and explanatory and should not be considered exclusive or extensive.
[0054] Further aspects and scopes of adaptability become apparent from the description provided herein. It should be understood that the various aspects of the present application may be implemented alone or in combination with one or more other aspects. It should also be understood that the description herein and the specific embodiments are for illustrative purposes only and are not intended to limit the scope of the present application.
[0055] The above has described in detail several embodiments of the present disclosure. However, it is obvious that those skilled in the art can make various modifications and variations to the embodiments of the present disclosure without departing from the spirit and scope of the present disclosure. The protection scope of the present disclosure is defined by the appended claims.< / cell> < / row> < / column> < / column>
Claims
1. A method for dynamically generating Excel files based on front-end configuration, characterized in that, Including: Receiving Excel template configuration information defined by a user on an Excel template customization interface, where the Excel template configuration information includes the attributes and methods of the template; Converting the Excel template configuration information into a structured XML template, where the structure of the XML template corresponds to that of the Excel template; Obtaining the filling data required for the Excel table from a database, an independent data set, or a data interface; And Parsing the XML template to extract the attributes and methods of the template, and dynamically generating an Excel table based on the extracted information and the filling data.
2. The method for dynamically generating an Excel file based on front-end configuration according to claim 1, wherein The receiving Excel template configuration information defined by a user on an Excel template customization interface, where the Excel template configuration information includes the attributes and methods of the template includes: Receiving the header fields, types, and default values, as well as the method names, parameter lists, and return types defined by the user for a preset template or a custom template on the Excel template configuration interface; and Receiving the storage path of the template defined by the user, and saving the configured template according to the storage path.
3. The method for dynamically generating an Excel file based on front-end configuration according to claim 2, wherein The receiving Excel template configuration information defined by a user on an Excel template customization interface, where the Excel template configuration information includes the attributes and methods of the template further includes: Receiving update and maintenance information of multiple users for the same Excel template; Sharing the configured Excel template with users within the Excel template configuration permissions.
4. The method for dynamically generating an Excel file based on front-end configuration according to claim 1, wherein The converting the Excel template configuration information into a structured XML template, where the structure of the XML template corresponds to that of the Excel template includes: Using a preset conversion tool to parse the Excel template, and extracting the header fields, field types, method definitions, styles, and format information from the Excel template; Defining the XML template structure so that the XML template structure corresponds one by one to the information extracted from the Excel template; and Converting each attribute, field, and rule in the Excel template configuration into XML format one by one, and mapping them to the XML template structure.
5. The method for dynamically generating an Excel file based on front-end configuration according to claim 1, wherein The obtaining the filling data required for the Excel table from a database, an independent data set, or a data interface includes: If the existing data interface in the system can provide the required data, using the data interface to obtain the Excel filling data; or Directly obtaining the Excel filling data from a data set independent of the database; or Obtaining the Excel filling data according to the return result of an SQL query statement; and Configuring the mapping relationship between the data source and the Excel template fields so as to fill the data into the Excel table according to the mapping relationship.
6. The method for dynamically generating an Excel file based on front-end configuration according to claim 1, wherein The parsing the XML template to extract the attributes and methods of the template, and dynamically generating an Excel table based on the extracted information and the filling data includes: Parsing the XML template to obtain Excel template definition information, where the Excel template definition information includes the header fields of Excel and the corresponding data sources, field attributes, method definitions, data formats, and rules; Clean the data obtained from the data source, perform corresponding format conversions on the data according to the field attributes, and fill the converted data into the corresponding columns of Excel; and Dynamically generate an Excel table based on the Excel template definition information and the filled data.
7. The method for dynamically generating an Excel file based on front-end configuration according to claim 6, wherein The dynamically generating an Excel table according to the Excel template definition information and the filled data includes: Generate an Excel table header based on the parsed header fields; For fields involving calculations or conversions, dynamically apply relevant functions according to the method definition; If the XML template contains style and format information, apply it to the cells of the Excel table according to the description of the XML template, and merge the cells in Excel according to the predefined rules.
8. The method for dynamically generating an Excel file based on front-end configuration according to claim 1, wherein The method further includes: Create an Excel file using openpyxl based on the parsed and processed data, and save the generated Excel file as a file stream in memory for direct download by users in the Web application.
9. A dynamic generation device for Excel files based on front-end configuration, characterized in that, The apparatus includes: At least one processor; and At least one memory storing a computer program; Wherein, when the computer program is executed by the at least one processor, the apparatus executes the steps of the method for dynamically generating an Excel file based on front-end configuration according to any one of claims 1 to 8.
10. A computer-readable storage medium storing a computer program, characterized in that, The computer program, when executed by a processor, implements the steps of the method for dynamically generating an Excel file based on front-end configuration according to any one of claims 1 to 8.
Citation Information
Patent Citations
System and method for quickly customizing and generating excel form, server and medium
CN111046643A
Excel form template generation method and device
CN111767704A
Table document online editing method and device, equipment and medium
CN114118038A
File generation method and device based on dynamic template, equipment and storage medium
CN117540716A
Excel table generation method and device
CN119808735A