Excel multi-configuration source import and export method and system
Patent Information
- Application Number
- CN202311741260.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-15
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-12-15
AI Technical Summary
[0008]本发明的目的在于提供一种excel多配置来源的导入导出方法及系统,解决现有的excel导入导出方法效率低的问题
Smart Images

Figure CN117787231B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically, to an import and export method and system for Excel with multiple configuration sources. Background Technology
[0002] Excel is a spreadsheet software. It is one of the most commonly used office automation applications, widely used for processing, analyzing, and storing data. Excel offers a powerful set of functions, including data entry, calculation, charts and graphs, data analysis, data filtering, and sorting, enabling users to easily perform various data processing tasks.
[0003] Excel plays a vital role in the workplace. It is widely used across various industries and fields, including finance, accounting, statistics, market research, project management, and human resources. Excel helps users process and analyze large amounts of data, perform complex calculations and modeling, generate reports and charts, and visualize data. It provides an intuitive interface and user-friendly features, enabling users to perform data processing and analysis quickly and flexibly.
[0004] In IT infrastructure development, Excel import / export solutions are a crucial component. Many organizations and enterprises need to interact with and integrate data from Excel files with other systems. Currently, there are numerous tools and methods available in various programming languages for modifying and reading Excel files, and many utilize web technologies such as HTTP / HTTPS interfaces to enable programs to import and export Excel files. However, this is only a very basic approach.
[0005] In practical applications, importing Excel files requires validation of the uploaded files, including verification of data validity (organizational structure, code tables), and business relevance before data can be stored in the database. However, validation conditions vary across different business functions, lacking universal validation rules. This necessitates rewriting code for validation and conversion for each new business import, resulting in significant unnecessary repetitive work. While visual, dynamic configuration of validation rules exists, these methods only support basic checks like time formatting, numbers, and NOT NULL. For validations requiring database queries, such as business relevance and data validity, online rule scripts are cumbersome, difficult to understand, and may not even meet the requirements. Furthermore, data relevance and validity are crucial aspects of data import validation.
[0006] In practical applications, while exporting Excel files doesn't involve strict data validation, it does place high demands on the format of the exported Excel spreadsheets. Different business units and companies have varying requirements for the exported Excel format. A relatively simple and native approach is based on charting, directly using Excel manipulation tools to iterate through the table row by row. However, this method is cumbersome, labor-intensive, inefficient, and requires code modifications for every change. Therefore, a more common approach is based on template file replacement. An Excel template is created, table styles are written within it, expressions are entered where data needs to be entered, and then Excel manipulation tools fill the data into the template based on these expressions before returning it to the user. This method improves development efficiency and reduces the difficulty of table format construction. However, this method requires the Excel template to be embedded in the code, and in actual use, business requirements change. The displayed columns and their positions may change, necessitating modification of the Excel template and redeployment of the service. This reduces application service stability and increases additional maintenance costs. Furthermore, data categories such as user names, organizational structures, and code tables are typically stored as corresponding codes or ID values, which need to be converted to a publicly displayed data format during export. Additionally, after data is populated, Excel cells may need to be merged. For each business logic, developers must rewrite code to call tools and data methods to process the data; these repetitive and tedious operations increase development costs and reduce development efficiency.
[0007] In view of the above, this application is hereby submitted. Summary of the Invention
[0008] The purpose of this invention is to provide an import and export method and system for Excel with multiple configuration sources, thereby solving the problem of low efficiency in existing Excel import and export methods.
[0009] This invention is achieved through the following technical solution:
[0010] On one hand, a method for importing and exporting Excel configurations from multiple sources is provided, including the following steps: defining a business configuration source interface class and adding implementation class objects to the business configuration manager in priority order; defining multiple business configuration methods in the business configuration source interface class; defining a data processing interface class and defining multiple data processing methods in the data processing interface class; defining an object conversion tool, which includes multiple data conversion methods; defining annotations based on Spring Validation for validating system object data; defining a fill tool, which integrates the data and methods for filling Excel templates into a fill configuration object and executes the fill methods based on the fill configuration object; encapsulating a constructor tool, which is used to fill the configuration object; setting up an Excel data reading interface, an Excel import interface, an Excel export interface, and an import example file download interface, and providing corresponding business coding parameters for each interface.
[0011] Furthermore, multiple business configuration methods are defined in the business configuration source interface class, including the following steps: Defining configuration method A1; configuration method A1 is used to obtain business configuration metadata through business coding parameters; the configuration metadata includes: exported template file ID, imported file format size limit, and imported example file ID; Defining configuration method B1; configuration method B1 is used to return template file metadata through file ID; the template file metadata includes: filename and file type; Defining configuration method C1; configuration method C1 is used to return file stream data through file ID; Multiple data processing methods are defined in the data processing interface class, including the following steps: Defining processing method A2; processing method A2 is used to query and return easyexcel reading rules for multiple Excel workbooks based on business coding; Defining processing method B2; processing method B2 is used to process the filtered and read Excel data; Defining processing method C2; processing method C2 is used to perform business processing based on the filtered Excel data and custom request parameters; Defining processing method D2; processing method D2 is used to return an Excel populate configuration object based on custom request parameters.
[0012] Furthermore, the Excel data reading interface is set up, including the following steps: Based on the business code, multiple configuration methods A1 are called in priority order in the configuration manager until configuration method A1 has valid data, then the business configuration is returned, and the interface parameters and file are verified with the configuration information; based on the business code, the corresponding interfaces are traversed in the Excel processing manager, and the import rules are returned by calling the processing method A2; according to the import rules, the imported Excel file is read using EasyExcel; Spring Validation is used to perform data checks, and if the check fails, a message indicating non-standard data is returned; the object tool is converted into a data model; the processing method B2 is called to filter the data, and the filtered data is given to the requester.
[0013] Furthermore, setting up the Excel import interface includes the following steps: Based on the business code, in the configuration manager, traverse and call multiple configuration methods A1 in priority order until configuration method A1 has valid data, then return the business configuration and verify the interface parameters and file with the configuration information; based on the business code, traverse the corresponding interfaces in the Excel processing manager and return the import rules by calling the processing method A2; based on the import rules, use EasyExcel to read the imported Excel file; use Spring Validation annotations to check the data, and if the check fails, return a message indicating non-standard data; convert the object tool into a data model; call the processing method B2 to filter the data; call the processing method C2 to perform business processing on the filtered data and return the processing result to the requester.
[0014] Furthermore, setting up the Excel export interface includes the following steps: Based on the business code, in the configuration manager, iterate through and call multiple configuration methods A1 in priority order until configuration method A1 has valid data, then return the business configuration and validate the interface parameters using the configuration information; based on the business code, in the Excel processing manager, iterate through the corresponding interfaces and fill the configuration object by calling the processing method B4; export the template file ID from the business configuration information, obtain the template file information by calling configuration method A2 in the configuration manager, and set the return information; based on the example file ID in the business configuration information, call configuration method A3 in the configuration manager to obtain the exported template file stream; use the fill tool to fill the configuration data into the Excel template file stream; return the filled Excel file stream to the requester.
[0015] Furthermore, setting up the import sample file download interface includes the following steps: Based on the business code, in the configuration manager, traverse and call multiple configuration methods A1 in priority order until the configuration method A1 has valid data, then return the business configuration and validate the interface parameters with the configuration information; based on the sample file ID in the business configuration information, call configuration method A2 in the configuration manager to obtain the sample file information and set the return information; based on the sample file ID in the business configuration information, call configuration method A3 in the configuration manager to obtain the export template file stream.
[0016] On the other hand, an import / export system for Excel with multiple configuration sources is provided, comprising: a business configuration interface class definition module, used to define business configuration source interface classes and add implementation class objects to the business configuration manager in priority order; defining multiple business configuration methods in the business configuration source interface classes; a data processing interface class definition module, used to define data processing interface classes and define multiple data processing methods in the data processing interface classes; an object conversion tool definition module, used to define object conversion tools, the object conversion tools containing multiple data conversion methods; an object data annotation definition module, used to define annotations for validating system object data based on Spring Validation; a fill tool definition module, used to define fill tools, the fill tools are used to integrate the data and methods for filling Excel templates into a fill configuration object, and execute the fill methods according to the fill configuration object; a constructor tool encapsulation module, used to encapsulate constructor tools, the constructor tools are used to fill configuration objects; and an interface setting module, used to set Excel data reading interface, Excel import interface, Excel export interface, and import example file download interface, and provide corresponding business coding parameters for each interface.
[0017] Furthermore, the business configuration interface class definition module includes: a first configuration method definition unit, used to define configuration method A1; configuration method A1 is used to obtain business configuration metadata through business coding parameters; the configuration metadata includes: exported template file ID, imported file format size limit, and imported example file ID; a second configuration method definition unit, used to define configuration method B1; configuration method B1 is used to return template file metadata through file ID; the template file metadata includes: file name and file type; a third configuration method definition unit, used to define configuration method C1; configuration method C1 is used to return file stream data through file ID.
[0018] Furthermore, the data processing interface class definition module includes: a first processing method definition unit for defining processing method A2; processing method A2 is used to query and return easyexcel reading rules for multiple Excel workbooks based on business codes; a second processing method definition unit for defining processing method B2; processing method B2 is used to process the filtered and read Excel data; a third processing method definition unit for defining processing method C2; processing method C2 is used to perform business processing based on the filtered Excel data and custom request parameters; and a fourth processing method definition unit for defining processing method D2; processing method D2 is used to return an Excel fill configuration object based on custom request parameters.
[0019] Furthermore, the interface setting module includes: a data reading interface setting unit, used to iterate and call multiple configuration methods A1 in priority order in the configuration manager according to the business code, until configuration method A1 has valid data and then return the business configuration, and verify the interface parameters and files with configuration information; according to the business code, iterate through the corresponding interfaces in the Excel processing manager and return the import rules by calling the processing method A2; according to the import rules, use EasyExcel to read the imported Excel file; use Spring Validation to perform data checks, and return a prompt message for non-standard data if the check fails; convert the object tool into a data model; call the processing method B2 to filter the data, and give the filtered data to the requester; and an import interface setting unit, used to iterate and call multiple configuration methods A1 in priority order in the configuration manager according to the business code, until configuration method A1 has valid data and then return the business configuration, and verify the interface parameters and files with configuration information; according to the business code, iterate through the corresponding interfaces in the Excel processing manager and return the import rules by calling the processing method A2; according to the import rules, use EasyExcel to read the imported Excel file; and use Spring Validation to perform data checks, and return a prompt message for non-standard data if the check fails; convert the object tool into a data model; call the processing method B2 to filter the data, and give the filtered data to the requester. The `@validation` annotation marks the data for inspection; if the inspection fails, a message indicating non-standard data is returned. The object tool is converted into a data model. Processing method B2 is called to filter the data. Processing method C2 is called to perform business processing on the filtered data and return the processing result to the requester. An interface setting unit is exported, used to iterate through and call multiple configuration methods A1 in the configuration manager according to the business code, until configuration method A1 has valid data, then returns the business configuration and validates the interface parameters using the configuration information. According to the business code, the corresponding interface is iterated through in the Excel processing manager, and the configuration object is populated by calling processing method B4. A template file ID is exported from the business configuration information; template file information is obtained by calling configuration method A2 in the configuration manager, and return information is set. Based on the example file ID in the business configuration information, configuration method A3 is called in the configuration manager to obtain the exported template file stream. The filling tool is used to fill the configuration data into the Excel template file stream. The filled Excel file stream is returned to the requester.
[0020] Furthermore, the data processing interface class definition module also includes: an example file download interface setting unit; the example file download interface setting unit is used to traverse and call multiple configuration methods A1 in the configuration manager according to the business code in priority order, until the configuration method A1 has valid data and then returns the business configuration, and validates the interface parameters with the configuration information; according to the example file ID in the business configuration information, it calls the configuration method A2 in the configuration manager to obtain the example file information and sets the return information; according to the example file ID in the business configuration information, it calls the configuration method A3 in the configuration manager to obtain the export template file stream.
[0021] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0022] 1. This invention enables simple and rapid development of Excel reading, importing, and exporting functions, eliminating the need for code development for common functions such as HTTP / HTTPS interfaces, access logs, access permissions, parameter checks, Excel data reading operations, and data validation error message responses. It simplifies the development of data validation, data conversion, and Excel template data filling operations. Furthermore, it provides a default exported template (a local template file) and a mechanism for real-time custom template updates, allowing the exported template file to be updated during normal service use without code modification or service restart. Developers do not need to concern themselves with the uploading, reading, and filling of Excel files.
[0023] 2. To read Excel files, simply implement the processing methods of the Java interface class for data processing, then register the implementation class with the Excel processing manager according to the business code. Then, access the unified reading interface, pass in the business code parameters and the corresponding Excel file, and you can get the data you need from the Excel file.
[0024] 3. Importing Excel files simply requires implementing the processing methods of a Java interface class for data processing. Then, the implementation class is registered with the Excel processing manager based on the business code. Subsequently, it accesses a unified import interface, passing in the business code parameters and the corresponding Excel file to retrieve the required data from the Excel file. Custom processing can then be performed within the processing methods. Sample files for importing Excel files can also be dynamically provided through an import template interface.
[0025] 4. To import Excel data, simply implement the processing methods of the Java interface class for data processing, then register the implementation class with the Excel processing manager according to the business code, and then access the unified export interface, passing in the business code and custom parameters to export the Excel data. Attached Figure Description
[0026] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a schematic diagram illustrating the processing logic of an Excel import / export method with multiple configuration sources, provided in an embodiment of the present invention.
[0028] Figure 2 This is a schematic diagram of an Excel import / export system framework with multiple configuration sources, provided as an embodiment of the present invention. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.
[0030] Example
[0031] The first aspect of this embodiment provides a method for importing and exporting Excel files from multiple configuration sources. The processing logic of this method can be found in [reference needed]. Figure 1 This includes the following steps:
[0032] Step 1: Define a Java interface class for the source of Excel business configurations, and add the implementation class objects to the business configuration manager in priority order; define the following 3 methods in the business configuration source interface class:
[0033] Configuration Method 1: Obtain the configuration metadata of the business through the business coding parameters, which mainly include the exported template file ID, the format and size limits of the imported file, and the imported example file ID.
[0034] Configuration Method 2: Return template file metadata via file ID, mainly including file name, file type, etc.
[0035] Configuration method 3: Return file stream data by file ID.
[0036] It should be noted that the interface implements a default business configuration source class based on Java IO to read template files locally. Local templates are named using a combination of business code, function description, and business name. It also implements another default business configuration source class that can load template files through an external visual service interface. The external service can visually upload and modify files, associating file ownership through business codes.
[0037] Step 2: Define a Java interface class for data processing. The interface includes methods for returning import rules, business logic, exporting data, and data processing. Developers implement the interface according to their business logic and add the implementation class object to the Excel processing manager. Specifically, define the following four processing methods:
[0038] Solution 1: Query the EasyExcel reading rules for multiple Excel workbooks based on the business code. The rules support reading lists and custom single cell data.
[0039] Method 2: Process the filtered Excel data.
[0040] Method 3: Perform business processing based on the filtered Excel data and custom request parameters.
[0041] Solution 4: Fill the configuration object with the returned Excel file based on the custom request parameters.
[0042] Step 3: Define a general-purpose system object (code table, user, organization, etc.) conversion tool. Provide data value conversion methods. Implement these data object conversion methods based on Java annotations and reflection mechanisms.
[0043] Step 4: Implement system object data validation functionality based on custom annotations in Spring Validation.
[0044] Step 5: Define a fill configuration object that integrates the data and methods for filling the Excel template, and encapsulate a utility object that uses the EasyExcel operation tool to execute the fill method based on the content of the fill configuration object.
[0045] Step 6: Based on the Builder design pattern, encapsulate tools for constructing population configuration objects. Provide functions including, but not limited to, population data settings, population data transformation operations, and population method configuration. New functions can also be added according to new requirements.
[0046] Step 7: Provide a unified HTTP / HTTPS protocol interface for reading Excel data, including a business-defined parameter and support for custom parameters. Specifically:
[0047] Step 7.1: Based on the business code, traverse and call multiple implementation configuration methods 1 in the configuration manager in priority order until the method has valid data, then interrupt the traversal and return the business configuration, and verify the interface parameters and files with the configuration information.
[0048] Step 7.2: Based on the business code, iterate through the Excel processing manager to obtain the corresponding business interface processing implementation, and call processing method 1 to return the import rules.
[0049] Step 7.3: Use EasyExcel to read the imported Excel file according to the import rules.
[0050] Step 7.4: Use Spring Validation to perform data checks based on the JSR-303 specification. If the check fails, return a message indicating that the data is not in compliance with the standard.
[0051] Step 7.5: Use the object tool to convert it into a data model.
[0052] Step 7.6: Call processing method 2 to filter the data, and then return the filtered data to the requester.
[0053] Step 8: Provide a unified HTTP / HTTPS protocol Excel import interface, and provide a business code parameter that also supports custom parameters.
[0054] Step 8.1: Based on the business code, traverse and call multiple implementations of configuration method 1 in the configuration manager in priority order until the method has valid data, then interrupt the traversal and return the business configuration, and verify the interface parameters, files, etc. with the configuration information.
[0055] Step 8.2: Based on the business code, iterate through the Excel processing manager to obtain the corresponding business interface processing implementation, and call processing method 1 to return the import rules.
[0056] Step 8.3: Use EasyExcel to read the imported Excel file according to the import rules.
[0057] Step 8.4: Use Spring Validation annotations to perform data checks based on the JSR-303 specification. If the check fails, return a message indicating that the data is not in compliance with the standard.
[0058] Step 8.5: Use the object tool to convert it into a data model.
[0059] Step 8.6: Call processing method 2 to filter the data.
[0060] Step 8.7: Call processing method 3 to perform business processing on the filtered data, and then return the processing result to the requester.
[0061] Step 9: Provide a unified export interface for the HTTP / HTTPS protocol, and provide a business code parameter that supports custom parameters.
[0062] Step 9.1: Based on the business code, traverse and call multiple implementations of configuration method 1 in the configuration manager in priority order until the method has valid data, then interrupt the traversal and return the business configuration, and verify the interface parameters with the configuration information.
[0063] Step 9.2: Based on the business code, iterate through the Excel processing manager to obtain the corresponding business interface processing implementation, and call processing method 4 to obtain the populate configuration object.
[0064] Step 9.3: Obtain the exported template file information by calling configuration method 2 in the configuration manager using the exported template file ID from the business configuration information, and set the return information.
[0065] Step 9.4: Obtain the exported template file stream by calling configuration method 3 in the configuration manager using the example file ID from the business configuration information.
[0066] Step 9.5: Use the fill tool to fill the configuration data into the Excel template file stream.
[0067] Step 9.6: Return the filled Excel file stream to the requester.
[0068] Step 10: Provide a unified interface for downloading sample files using the HTTP / HTTPS protocol, and provide a parameter for business code.
[0069] Step 10.1: Based on the business code, traverse and call multiple implementations of configuration method 1 in the configuration manager in priority order until the method has valid data, then interrupt the traversal and return the business configuration information, and verify the interface parameters with the configuration information.
[0070] Step 10.2: Obtain sample file information by calling configuration method 2 in the configuration manager using the sample file ID from the business configuration information, and set the return information.
[0071] Step 10.3: Use the example file ID in the business configuration information to call configuration method 3 in the configuration manager to obtain the exported template file stream.
[0072] Secondly, it provides an import / export system for Excel with multiple configuration sources, with a system framework referenced. Figure 2 ,include:
[0073] The business configuration interface class definition module is used to define the business configuration source interface class, add the implementation class objects to the business configuration manager in priority order, and define multiple business configuration methods in the business configuration source interface class.
[0074] The data processing interface class definition module is used to define a data processing interface class, in which multiple data processing methods are defined.
[0075] An object conversion tool definition module is used to define object conversion tools, which include various data conversion methods;
[0076] The object data annotation definition module is used to define annotations for validating system object data based on Spring Validation.
[0077] The fill tool definition module is used to define fill tools, which are used to integrate the data and methods for filling an Excel template into a fill configuration object, and execute the fill method according to the fill configuration object;
[0078] A construction tool encapsulation module is used to encapsulate construction tools, which are used to populate configuration objects;
[0079] The interface settings module is used to set up the Excel data reading interface, Excel import interface, Excel export interface, and import sample file download interface, and provides corresponding business code parameters for each interface.
[0080] The business configuration interface class definition module includes: a first configuration method definition unit, used to define configuration method A1; configuration method A1 is used to obtain business configuration metadata through business coding parameters; the configuration metadata includes: exported template file ID, imported file format and size limits, and imported example file ID; a second configuration method definition unit, used to define configuration method B1; configuration method B1 is used to return template file metadata through file ID; the template file metadata includes: file name and file type; and a third configuration method definition unit, used to define configuration method C1; configuration method C1 is used to return file stream data through file ID.
[0081] The data processing interface class definition module includes: a first processing method definition unit for defining processing method A2; processing method A2 is used to query and return easyexcel reading rules for multiple Excel workbooks based on business codes; a second processing method definition unit for defining processing method B2; processing method B2 is used to process the filtered and read Excel data; a third processing method definition unit for defining processing method C2; processing method C2 is used to perform business processing based on the filtered Excel data and custom request parameters; and a fourth processing method definition unit for defining processing method D2; processing method D2 is used to return an Excel fill configuration object based on custom request parameters.
[0082] The interface settings module includes:
[0083] The data reading interface setting unit is used to iterate and call multiple configuration methods A1 according to the priority order in the configuration manager based on the business code, until configuration method A1 has valid data, and then return the business configuration, and verify the interface parameters and files with the configuration information; according to the business code, it iterates through the corresponding interfaces in the Excel processing manager, and returns the import rules by calling the processing method A2; according to the import rules, it uses EasyExcel to read the imported Excel file; it uses Spring Validation to perform data checks, and returns a prompt message for non-standard data if the check fails; it converts the object tool into a data model; it calls the processing method B2 to filter the data, and the filtered data is given to the requester;
[0084] The import interface setting unit is used to iterate through and call multiple configuration methods A1 in the configuration manager according to the business code, until configuration method A1 has valid data, and then return the business configuration and verify the interface parameters and files with the configuration information; according to the business code, it iterates through the corresponding interfaces in the Excel processing manager and returns the import rules by calling the processing method A2; according to the import rules, it uses EasyExcel to read the imported Excel file; it uses Spring Validation annotations to check the data, and if the check fails, it returns a message indicating non-standard data; it converts the object tool into a data model; it calls the processing method B2 to filter the data; it calls the processing method C2 to perform business processing on the filtered data and returns the processing result to the requester;
[0085] The export interface setting unit is used to iterate through and call multiple configuration methods A1 in the configuration manager according to the business code, in order of priority, until configuration method A1 has valid data, and then return the business configuration and validate the interface parameters through the configuration information; according to the business code, it iterates through the corresponding interface in the Excel processing manager and fills the configuration object by calling the processing method B4; it exports the template file ID from the business configuration information, obtains the template file information by calling the configuration method A2 in the configuration manager, and sets the return information; according to the sample file ID in the business configuration information, it calls the configuration method A3 in the configuration manager to obtain the exported template file stream; it uses the fill tool to fill the configuration data into the Excel template file stream; and it returns the filled Excel file stream to the requester.
[0086] The example file download interface setting unit is used to iterate and call multiple configuration methods A1 in the configuration manager according to priority based on the business code, until the configuration method A1 has valid data and then returns the business configuration, and validates the interface parameters with the configuration information; according to the example file ID in the business configuration information, the configuration method A2 is called in the configuration manager to obtain the example file information and set the return information; according to the example file ID in the business configuration information, the configuration method A3 is called in the configuration manager to obtain the export template file stream.
[0087] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for importing and exporting Excel files from multiple configuration sources, characterized in that, Includes the following steps: Define a business configuration source interface class, and add the implementation class objects to the business configuration manager in priority order; define multiple business configuration methods in the business configuration source interface class; Define a data processing interface class, and define multiple data processing methods in the data processing interface class; Define an object transformation tool, which includes various data transformation methods; Annotations used for validating system object data are defined based on Spring Validation; Define a fill tool, which integrates the data and methods for filling an Excel template into a fill configuration object, and executes the fill method based on the fill configuration object; An encapsulated constructor is provided, which is used to populate a configuration object; Set up an Excel data reading interface, an Excel import interface, an Excel export interface, and an import sample file download interface, and provide corresponding business code parameters for each interface; The business configuration source interface class defines multiple business configuration methods, including the following steps: Define configuration method A1; configuration method A1 is used to obtain configuration metadata of the business through business coding parameters; the configuration metadata includes: export template file ID, import file format and size limit, and import example file ID; Define configuration method B1; configuration method B1 is used to return template file metadata by file ID; the template file metadata includes: file name and file type; Define configuration method C1; configuration method C1 is used to return file stream data by file ID; The data processing interface class defines multiple data processing methods, including the following steps: Define processing method A2; processing method A2 is used to query and return the EasyExcel reading rules for multiple Excel workbooks based on the business code; Define processing method B2; processing method B2 is used to process the Excel data obtained by filtering and reading. Define processing method C2; processing method C2 is used to perform business processing based on the filtered Excel data and custom request parameters. Define processing method D2; processing method D2 is used to return an Excel file to populate the configuration object based on custom request parameters.
2. The method for importing and exporting Excel files from multiple configuration sources according to claim 1, characterized in that, Setting up an Excel data reading interface includes the following steps: Based on the business code, the configuration method A1 is called repeatedly in the priority order in the configuration manager until the configuration method A1 has valid data. Then the business configuration is returned, and the interface parameters and files are verified with the configuration information. Based on the business code, the corresponding interfaces are traversed in the Excel processing manager, and the import rules are returned by calling the processing method A2. Based on the import rules, use EasyExcel to read the imported Excel file; Use Spring Validation to perform data checks, and return a message indicating non-compliant data if the check fails. Convert object tools into data models; The processing method B2 is invoked to filter the data, and the filtered data is given to the requester.
3. The method for importing and exporting Excel files from multiple configuration sources according to claim 1, characterized in that, Setting up the Excel import interface involves the following steps: Based on the business code, multiple configuration methods A1 are called in priority order in the configuration manager until the configuration method A1 has valid data. Then the business configuration is returned, and the interface parameters and files are verified with the configuration information. Based on the business code, the corresponding interfaces are traversed in the Excel processing manager, and the import rules are returned by calling the processing method A2. Based on the import rules, use EasyExcel to read the imported Excel file; Use the Spring Validation annotation to mark the data for inspection. If the inspection fails, return a message indicating that the data is not in compliance with the standard. Convert object tools into data models; The data is filtered by calling the processing method B2. The processing method C2 is invoked to perform business processing on the filtered data and return the processing result to the requester.
4. The method for importing and exporting Excel files from multiple configuration sources according to claim 1, characterized in that, Setting up the Excel export interface involves the following steps: Based on the business code, multiple configuration methods A1 are called in the configuration manager in priority order until the configuration method A1 has valid data. Then the business configuration is returned, and the interface parameters are verified through the configuration information. Based on the business code, traverse the corresponding interfaces in the Excel processing manager and obtain the fill configuration object by calling the processing method B4; Export the template file ID from the business configuration information, obtain the template file information by calling the configuration method A2 in the configuration manager, and set the return information; Based on the sample file ID in the business configuration information, call configuration method A3 in the configuration manager to obtain the export template file stream; Use the fill tool to populate the configuration data into the Excel template file stream; Return the filled Excel file stream to the requester.
5. The method for importing and exporting Excel files from multiple configuration sources according to claim 1, characterized in that, Setting up the import sample file download interface involves the following steps: Based on the business code, multiple configuration methods A1 are called in the configuration manager in priority order until the configuration method A1 has valid data. Then the business configuration is returned and the interface parameters are validated with the configuration information. Based on the sample file ID in the business configuration information, call configuration method A2 in the configuration manager to obtain the sample file information and set the return information; Based on the sample file ID in the business configuration information, the configuration method A3 is called in the configuration manager to obtain the export template file stream.
6. An Excel import / export system with multiple configuration sources, characterized in that, include: The business configuration interface class definition module is used to define the business configuration source interface class, add the implementation class objects to the business configuration manager in priority order, and define multiple business configuration methods in the business configuration source interface class. The data processing interface class definition module is used to define a data processing interface class, in which multiple data processing methods are defined. An object conversion tool definition module is used to define object conversion tools, which include various data conversion methods; The object data annotation definition module is used to define annotations for validating system object data based on Spring Validation. The fill tool definition module is used to define fill tools, which are used to integrate the data and methods for filling an Excel template into a fill configuration object, and execute the fill method according to the fill configuration object; A construction tool encapsulation module is used to encapsulate construction tools, which are used to populate configuration objects; The interface settings module is used to set up the Excel data reading interface, Excel import interface, Excel export interface, and import sample file download interface, and provides corresponding business code parameters for each interface. The business configuration interface class definition module includes: The first configuration method definition unit is used to define configuration method A1; the configuration method A1 is used to obtain the configuration metadata of the business through the business coding parameters; the configuration metadata includes: export template file ID, import file format and size limit and import example file ID; The second configuration method definition unit is used to define configuration method B1; the configuration method B1 is used to return template file metadata through file ID; the template file metadata includes: file name and file type; The third configuration method definition unit is used to define configuration method C1; the configuration method C1 is used to return file stream data through file ID; The data processing interface class definition module includes: The first processing method definition unit is used to define processing method A2; the processing method A2 is used to query and return the easyexcel reading rules of multiple Excel workbooks according to the business code. The second processing method definition unit is used to define processing method B2; the processing method B2 is used to process the Excel data obtained by filtering and reading. The third processing method definition unit is used to define processing method C2; the processing method C2 is used to perform business processing based on the filtered Excel data and custom request parameters. The fourth processing method definition unit is used to define processing method D2; the processing method D2 is used to return an Excel populate configuration object based on the custom request parameters.
7. An Excel import / export system with multiple configuration sources according to claim 6, characterized in that, The interface setting module includes: The data reading interface setting unit is used to iterate and call multiple configuration methods A1 according to the priority order in the configuration manager based on the business code, until configuration method A1 has valid data, and then return the business configuration, and verify the interface parameters and files with the configuration information; according to the business code, it iterates through the corresponding interfaces in the Excel processing manager, and returns the import rules by calling the processing method A2; according to the import rules, it uses EasyExcel to read the imported Excel file; it uses SpringValidation to perform data checks, and returns a prompt message for non-standard data if the check fails; it converts the object tool into a data model; it calls the processing method B2 to filter the data, and the filtered data is given to the requester; The import interface setting unit is used to iterate through and call multiple configuration methods A1 in the configuration manager according to the business code, until configuration method A1 has valid data, and then return the business configuration and verify the interface parameters and files with the configuration information; according to the business code, it iterates through the corresponding interfaces in the Excel processing manager and returns the import rules by calling the processing method A2; according to the import rules, it uses EasyExcel to read the imported Excel file; it uses the SpringValidation annotation to check the data, and if the check fails, it returns a message indicating non-standard data; it converts the object tool into a data model; it calls the processing method B2 to filter the data; it calls the processing method C2 to perform business processing on the filtered data and returns the processing result to the requester; The export interface setting unit is used to iterate through and call multiple configuration methods A1 in the configuration manager according to the business code, in order of priority, until configuration method A1 has valid data, and then return the business configuration and validate the interface parameters through the configuration information; according to the business code, it iterates through the corresponding interface in the Excel processing manager and obtains the fill configuration object by calling the processing method B4; it exports the template file ID from the business configuration information, obtains the template file information by calling the configuration method A2 in the configuration manager, and sets the return information; according to the sample file ID in the business configuration information, it calls the configuration method A3 in the configuration manager to obtain the exported template file stream; it uses the fill tool to fill the fill configuration data into the Excel template file stream; and it returns the filled Excel file stream to the requester. The example file download interface setting unit is used to iterate and call multiple configuration methods A1 in the configuration manager according to priority based on the business code, until the configuration method A1 has valid data and then returns the business configuration, and validates the interface parameters with the configuration information; according to the example file ID in the business configuration information, the configuration method A2 is called in the configuration manager to obtain the example file information and set the return information; according to the example file ID in the business configuration information, the configuration method A3 is called in the configuration manager to obtain the export template file stream.
Citation Information
Patent Citations
General Excel import method based on configuration
CN102609483A
Configuration report development method based on Springboot + vue framework
CN115185520A
