Configuration table data exporting method and system for query list page
By using configurable design and Java reflection mechanism to dynamically invoke business methods, the problems of low development efficiency and high system coupling in the Excel data export function are solved, enabling rapid response to business needs and efficient generation of Excel files, thus improving the system's flexibility and scalability.
Patent Information
- Application Number
- CN202511068436.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-31
- Publication Date
- 2025-11-04
AI Technical Summary
Existing technologies for implementing Excel data export functions suffer from low development efficiency, insufficient flexibility, and high system coupling, resulting in poor system scalability and maintainability, and difficulty in quickly responding to changes in business needs.
The system employs a configurable design and reflection mechanism, storing export template information, including file name, sheet page information, and field-to-header mapping, in a database table. It then uses a unified interface and Java reflection to dynamically invoke business methods and generate Excel files.
It enables dynamic configuration support, reduces system coupling, improves development efficiency and flexibility, reduces code redundancy, supports rapid response to changes in business requirements, reduces failure risks, and is suitable for high-concurrency scenarios and enterprise-level data platforms.
Smart Images

Figure CN120893409A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of table data processing, and particularly relates to a configuration table data export method and system for a query list page. BACKGROUND
[0002] The statements in this section merely provide background information related to the present application and do not necessarily constitute prior art.
[0003] Implementing the export of Excel table data is a common business requirement. Currently, the implementation of this function mainly relies on third-party libraries. However, in actual business systems, the demand for exporting Excel files is often diverse and complex. The Excel files that need to be exported from different pages or business scenarios usually have different table header structures and data sources, such as user information tables, order information tables, etc. This difference requires developers to write specific code logic for each export task to meet different business requirements.
[0004] Therefore, when a new export task needs to be added, developers need to rewrite the code logic, including defining the table header structure, specifying the data source, setting the cell style, etc. This approach not only consumes time and effort, but also easily leads to code redundancy and repetition, resulting in long export function time.
[0005] On the other hand, since the export logic is hard-coded in the code, when business requirements change, such as adjusting the table header structure or adding data fields, developers need to modify the code to adapt to the new requirements. This hard-coded approach makes it difficult for the system to quickly respond to changes in business requirements, reducing the system's flexibility.
[0006] In addition, current export logic is usually deeply bound to business code, and there is a close dependency relationship between export function and other business functions. When the business code changes, it may affect the normal operation of the export function, which increases the complexity and maintenance cost of the system due to high coupling.
[0007] In summary, the existing technology has the disadvantages of low development efficiency, insufficient flexibility, and high system coupling when implementing the Excel data export function. These problems limit the scalability and maintainability of the system, increasing the workload of developers. SUMMARY
[0008] To solve the above problems, the present application proposes a configuration table data export method and system for a query list page, which can effectively eliminate repeated coding, improve development efficiency, support dynamic configuration, improve flexibility, decouple business systems, and reduce the risk of failure.
[0009] According to some embodiments, the present application adopts the technical solutions as follows: A configuration table data export method of a query list page, comprising the following steps: In response to a configuration table data export request, configuration export template information is configured, and the configuration content includes a file name, Sheet page information, and a mapping relationship between a field and a header; A unified export interface is called, and relevant parameters of the export file are transmitted, and it is determined whether the relevant parameters are valid, if so, the file name, Sheet page set, and relevant field are obtained; By using a reflection mechanism, a business method parameter list is obtained through relevant parameters, the parameters are dynamically transmitted, the transmitted parameters are sequentially assigned to the business method parameter list, and the data to be exported is obtained; According to the configured export template information, the obtained data to be exported is filled into the export template information, and a final export table file is generated.
[0010] As an optional implementation, the export template information includes a table file information table, a Sheet page information table, and a table field information table.
[0011] As a further implementation, the table file information table includes a primary key, a globally unique file identifier, and a file naming rule; The Sheet page information table includes a primary key, a Sheet page unique identifier, a Sheet page display name, a Sheet page arrangement order, a foreign key, and a core business interface name; The table field information table includes a primary key, an original field name returned by a business interface, a table column display name, a table field display order, and a foreign key; One globally unique file identifier corresponds to multiple Sheet page unique identifiers, and one Sheet page unique identifier corresponds to multiple original field names returned by a business interface.
[0012] As an optional implementation, the process of calling a unified export interface and transmitting relevant parameters of the export file includes: calling a unified interface through a url method, and the first parameter, the second parameter, and the third parameter need to be transmitted, the first parameter represents a file stream after a user writes a method execution, and is used to generate a corresponding result file; the second parameter is a data to be exported mark, which corresponds to the globally unique file identifier in the table file information table; and the third parameter is the type of the business method parameter list, the number of elements of the business method parameter list needs to be consistent with the number of Sheet pages of the corresponding export table file, and all need to be consistent with the required parameters of the corresponding business interface.
[0013] As an alternative embodiment, the process of judging whether the related parameters are valid includes: calling file name acquisition logic to acquire the file name, for the purpose of naming the later exported file; Calling the logic of acquiring the Sheet page collection to acquire the corresponding Sheet page, as well as the name and arrangement order of the Sheet page, to lay the foundation for the later data writing; Calling the logic of acquiring the fields of each Sheet to acquire the corresponding field collection.
[0014] As an alternative embodiment, the dynamic transmission of the parameters includes: in the process of assigning the parameters to the business method parameter list in order, performing data collection processing, forcibly converting the return value to a predetermined type, and ensuring data format uniformity; If the return value is invalid, it is automatically replaced by an empty set to avoid empty pointer exceptions when generating a table.
[0015] As an alternative embodiment, the process of filling the acquired data to be exported into the export template information to generate the final export table file includes: According to the acquired Sheet page total number; Parsing the Sheet page configuration to extract the names of all Sheet pages and generate an ordered list; Creating a predetermined object as a table file container; Acquiring the header configuration, parsing the header configuration, and generating an ordered list of header display names and a list of header field IDs; Creating a Sheet page and a header; Iterating through the data collection of the current Sheet page to fill in the data content; Taking the 0th row as the header and the data starting from the 1st row, with the 0th column as the serial number, sequentially iterating, and filling the data fields in the subsequent columns in the order of the header list; Acquiring the field ID, extracting the corresponding value from the number list, and automatically filling in an empty string when the value is invalid; Setting the HTTP response header, writing the predetermined object to the response output stream, and sequentially closing the workbook.
[0016] A configuration table data export system for a query list page, comprising: A configuration module configured to configure export template information in response to a configuration table data export request, and the configuration content includes file name, Sheet page information, and the mapping relationship between fields and headers; A calling module configured to call a unified export interface, input the related parameters of the export file, judge whether the related parameters are valid, if valid, acquire the file name, Sheet page collection, and related fields; The reflection module is configured to utilize a reflection mechanism to acquire a business method parameter list through a related parameter, dynamically transmit the parameter, assign the transmitted parameter to the business method parameter list according to an order, and acquire data to be exported. The export module is configured to fill the acquired data to be exported into the export template information according to the configured export template information, and generate a final export table file.
[0017] A computer readable storage medium is used to store computer instructions, which are executed by a processor to complete the steps in the above method.
[0018] An electronic device includes a memory and a processor, and computer instructions stored on the memory and running on the processor, which are executed by the processor to complete the steps in the above method.
[0019] Compared with the prior art, the beneficial effects of the present application are: The present application significantly improves the technical implementation effect while reducing the system coupling degree through the configuration design and the structure of the reflection mechanism.
[0020] The present application stores the export template configuration in a database table, can quickly respond to demand changes, supports new template types without modifying the code, realizes the "configuration-driven development" mode, has strong dynamic adaptation capability, only needs to configure the field mapping relationship when adding new export functions, does not need to repeatedly develop the underlying logic, avoids the code bloat problem caused by function expansion in traditional development, and enhances the expansibility.
[0021] The present application dynamically calls the data interface based on the reflection mechanism, eliminates the direct dependence of the export function on the business module, reduces the control coupling between modules, centrally processes all export requests through a single entrance, reduces the functional fragmentation, solves the public coupling risk (such as global variable abuse) caused by scattered development in traditional implementation, and realizes unified interface management.
[0022] The reflection mechanism of the present application only loads the configuration in the initialization stage, directly calls the pre-compiled logic during actual export, avoids the persistent impact of reflection on performance, reduces the amount of repeated coding through the configuration template, and enables the developers to focus on the core business logic, so that the team collaboration efficiency is significantly improved.
[0023] The configuration information of the present application is independently stored, avoids the sensitive data leakage risk caused by hard coding, meets the strict requirements of the financial industry and other industries on data security, and is compatible with mainstream Java frameworks through the reflection mechanism, supports multi-version iteration through unified interface design, and reduces the adaptation cost of system upgrade.
[0024] The application supports dynamic generation of complex table structures that meet regulatory requirements, while meeting the stability requirements in high concurrency scenarios; through configuration, the export template differences of different business departments are quickly adapted, avoiding code branch conflicts, and being suitable for enterprise-level data middle platform.
[0025] In order to make the above-mentioned objects, features and advantages of the present application more apparent, a preferred embodiment is described below, and the accompanying drawings are described in detail as follows. BRIEF DESCRIPTION OF DRAWINGS
[0026] The drawings constituting a part of the specification of the present application are used to provide a further understanding of the present application, the schematic embodiments of the present application and the description thereof are used to explain the present application, and do not constitute an improper limitation on the present application.
[0027] Figure 1 It is a flowchart of a table data export method of an embodiment; Figure 2 It is a table file information representation intent of an embodiment; Figure 3 It is a Sheet page information representation intent of an embodiment; Figure 4 It is a table field information representation intent of an embodiment; Figure 5 It is a flowchart of related parameters of an incoming export file of an embodiment; Figure 6 It is a flowchart of a reflection mechanism of an embodiment. DETAILED DESCRIPTION
[0028] The present application will be further described below in combination with the drawings and embodiments.
[0029] It should be pointed out that the following detailed description is exemplary and is intended to provide further description of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as generally understood by those skilled in the art to which the present application belongs.
[0030] It should be noted that the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is intended to include the plural form, and in addition, it should be understood that when the terms "comprise" and / or "include" are used in the specification, they indicate the presence of a feature, step, operation, device, component and / or combination thereof.
[0031] The embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0032] Embodiment one A method for exporting configurable tabular data from a query list page, such as... Figure 1 As shown, it includes the following steps: In response to a configurable table data export request, configure the export template information, including the file name, sheet page information, and the mapping relationship between fields and table headers; Call the unified export interface, pass in the relevant parameters of the export file, check whether the relevant parameters are valid, and if valid, get the file name, the set of Sheet pages and relevant fields; By using reflection, the list of business method parameters is obtained through relevant parameters, the parameters are dynamically passed in, and the passed parameters are assigned to the list of business method parameters in order to obtain the data to be exported. Based on the configured export template information, the acquired data to be exported is filled into the export template information to generate the final export table file.
[0033] The process of configuring the export template information, which includes the file name, sheet page information, and the mapping relationship between fields and table headers, specifically includes: The exported template information mainly consists of three data tables. These three tables construct and describe the basic and structural information of the Excel file to be exported, including the file name of the Excel file to be exported, information about the sheets it contains, and field information for each sheet. These are respectively excel_meta_file (Excel file information table), excel_meta_sheet (Excel sheet information table), and excel_meta_cols (Excel field information table). Their specific design is as follows: Figures 2-4 As shown.
[0034] First is the Excel file information table, namely excel_meta_file; like Figure 2 As shown, its function is defined as: users store global configuration information for exporting Excel files, with each record corresponding to an independent export template.
[0035] Description of relevant fields: Id: Primary key, uniquely identifies a file configuration record (auto-incrementing number).
[0036] file_id: A globally unique file identifier used for: Associate the excel_meta_sheet table and retrieve the configuration of all sheet pages contained in that file; As a request parameter for the export interface, it distinguishes different templates (e.g., finance_report identifies the financial template).
[0037] file_name: naming rules for exported Excel files, supporting dynamic variables (example: #{date}_sales report.xlsx).
[0038] As shown in Figure 3 excel sheet page information table, i.e. excel_meta_sheet: Function definition: Define the structure and data source of each Sheet page in the Excel file, supporting multiple Sheet configurations.
[0039] Field description Id: primary key, uniquely identifies a Sheet page configuration record.
[0040] sheet_id: Sheet page unique identifier, used to associate the excel_meta_cols table to obtain all field configurations for the Sheet.
[0041] sheet_name: display name of the Sheet page in the Excel file (e.g. "Customer Details" "Order Summary").
[0042] sheet_order: controls the arrangement order of multiple Sheet pages (the smaller the value, the closer to the left, e.g. 1 indicates the first Sheet).
[0043] file_id: foreign key, pointing to excel_meta_file.file_id, indicating the Excel file to which the current Sheet belongs (when multiple Sheets belong to the same file, the values of this field are the same).
[0044] method_name: core business interface name, dynamically call the data source through the reflection mechanism (e.g. UserService.getExportData()), the return value of the interface will be filled into the current Sheet.
[0045] As shown in Figure 4 excel field information table, i.e. excel_meta_cols.
[0046] Function definition: control the column field mapping rules of each Sheet page, including display name, order, etc.
[0047] Field description: Id: primary key, uniquely identifies a field configuration record.
[0048] col_id: original field name returned by the business interface (must match the interface JSON field strictly, e.g. userName).
[0049] col_name: Excel column display name (customizable, such as mapping userName to "Username").
[0050] col_order: Control the order of the field in Excel (the smaller the value, the closer to the left, such as 0 for the first column).
[0051] sheet_id: Foreign key, pointing to excel_meta_sheet.sheet_id, indicating the Sheet page to which the current field belongs (one Sheet can be associated with multiple field configurations).
[0052] There is a hierarchical relationship, file→Sheet: one file_id corresponds to multiple sheet_id (one-to-many); Sheet→field: one sheet_id corresponds to multiple col_id (one-to-many).
[0053] Call the unified export interface, pass in the relevant parameters of the exported file, and judge whether the relevant parameters are valid. If valid, the process of obtaining the file name, Sheet page set and related fields includes: Users can call the unified interface through url, which needs to pass in HttpServletResponse response, String expFlag, List<Map<String, Object>>param three parameters.
[0054] Among them, response user write method execution completed after the file stream, used to generate the corresponding result file. expFlag parameter for the data to be exported mark, it corresponds to file_id in excel_meta_file table. param for List <map>The type is the parameter list of the business interface. The number of its elements must be consistent with the number of sheets in the corresponding exported Excel file, and all of them must be consistent with the required parameters of the corresponding business interface.
[0055] When the unified interface receives the above three parameters, such as Figure 5 As shown, perform the following steps: (1) The core of the logic for retrieving the file name is to execute the SQL statement "select file_id fileId, file_name fileName from excel_meta_file s where s.file_id like #{expFlag}" to retrieve the file name, which is used to name the exported file later.
[0056] (2) Call the logic to get the set of sheet pages. The core is to execute the SQL "select s.sheet_id sheetId,s.sheet_name sheetName, s.method_name methodName from excel_meta_sheet swhere s.file_id = #{fileId} order by sheet_order asc". The purpose is to get the corresponding sheet pages, as well as the names and order of the sheet pages, to lay the groundwork for the subsequent data writing.
[0057] (3) The logic for retrieving the fields of each sheet is to execute the SQL statement "select col_id colId,col_name colNamefrom excel_meta_cols s where s.sheet_id like #{sheetId} orderby s.col_order" to obtain the corresponding set of fields. A List is also used for storage to ensure the fields are ordered. The process of using reflection to obtain a list of business method parameters, dynamically passing in these parameters, assigning values to the business method parameter list in sequence, and retrieving the data to be exported is as follows: Figure 6 As shown, it includes: (1) Obtaining the list of business methods Call data acquisition logic, through the fileId parameter associated with the relevant data table acquisition business method set, the core is to execute "select s.method_name methodName from excel_meta_sheet s where s.file_id = #{fileId} order by sheet_order asc" to get the business method list, the need to maintain the order of the method.
[0058] (2) Analysis and binding of parameters Through the java reflection mechanism, the business method is parsed in turn, the business method parameter list is obtained, and the input parameter parm is assigned to the parameter list according to the order. At this time, the program needs to be controlled by exception, because the normal execution of the program needs to rely on the ordered and correct transmission of business parameters.
[0059] In the implementation of Excel data export function, the traditional method usually needs to hard code the export logic in the business code, which leads to the problems of low development efficiency, insufficient flexibility and high system coupling degree. In order to solve these problems, the embodiment proposes a configuration Excel data export method, in which the java reflection mechanism plays a key role.
[0060] The specific process of analyzing business method through java reflection mechanism includes: (a) Configure export template: The export template information is designed and configured in the database, including file name, Sheet page information and the mapping relationship between field and table header. These information are stored in the three data tables of excel_meta_file, excel_meta_sheet and excel_meta_cols.
[0061] (b) Call unified export interface: Users call the unified export interface through URL method, and input necessary parameters. These parameters include HttpServletResponse object (used to write file stream), export data marker (corresponding to file_id in excel_meta_file table) and business interface parameter list.
[0062] (c) Reflective analysis of interface data: In the process of interface calling, the system dynamically calls the data acquisition interface specified in the configuration through Java reflection mechanism. This step is the core of the application of reflection mechanism.
[0063] Specifically, the system first obtains the corresponding method_name (i.e., business interface name) from the excel_meta_sheet table according to the incoming file_id parameter.
[0064] Then, the system uses Java reflection API (such as Class.forName(), Class.getMethod(), and Method.invoke()) to dynamically load and call these business interfaces.
[0065] During the calling process, the system also needs to bind the incoming business parameter list to the parameter list of the business method in order. This step ensures the correct execution of the business method and the accurate acquisition of data.
[0066] (d) Reflection analysis interface data: After obtaining the data, the system fills the data into the Excel file according to the configured template information and generates the final export file.
[0067] This embodiment can achieve the separation of export logic and business logic by using the reflection mechanism, reducing the coupling degree of the system. The reflection mechanism enables the system to dynamically call different business interfaces, improving flexibility and expandability.
[0068] This embodiment stores detailed export configuration information, including business interface names and parameter mapping relationships, in a database table when configuring the export template. This provides necessary information support for the dynamic call of the reflection mechanism.
[0069] When calling the unified export interface, the system can accurately locate the business interface and method to be called by analyzing the incoming parameters and configuration information.
[0070] During the reflection analysis interface data process, the system performs ordered transmission and exception control of business parameters, ensuring the stability and reliability of the program.
[0071] In summary, this embodiment does not directly use existing methods when using the Java reflection mechanism, but has unique designs in the analysis and data acquisition process. These designs enable the system to flexibly call different business interfaces, accurately acquire data, and generate Excel export files that meet the requirements.
[0072] The exception control of this embodiment includes: For potential NoSuchMethodException (method not found exception), IllegalAccessException (illegal access exception), InvocationTargetException (method invocation exception), etc., design different exception handling logic.
[0073] Implementation steps of exception control Capture common reflection exceptions: Before calling the method through reflection, use a try-catch block to catch NoSuchMethodException, ensuring that the called method actually exists.
[0074] Catch IllegalAccessException to ensure that the method has permission to access.
[0075] After the method is called, catch InvocationTargetException to handle any exceptions thrown during method execution.
[0076] Parameter verification and exception handling: Before assigning the incoming parameter parm to the business method parameter list, perform parameter verification to ensure that the number, type, and order of parameters are consistent with the requirements of the business method.
[0077] If parameter verification fails, throw a custom IllegalArgumentException, and catch and handle it at the upper call.
[0078] Logging and error tracking: In the exception handling code, add logging functions to record the time, location, and reason of the exception.
[0079] Use a logging framework (such as Log4j, SLF4J, etc.) to control the log level, so that the log output can be adjusted flexibly during development and operation.
[0080] User-friendly error prompt: For front-end users or callers, design simple and clear error prompt information to avoid exposing too many internal implementation details.
[0081] When necessary, provide links or documents for error codes so that users or callers can find solutions on their own.
[0082] Recovery strategy and fault tolerance mechanism: According to business needs and system architecture, design reasonable recovery strategy and fault tolerance mechanism. For example, when data export fails, you can choose to roll back or record error information and continue executing other tasks.
[0083] Ensure that the system can maintain a stable running state after an exception occurs, avoiding single-point failure leading to the collapse of the entire system.
[0084] (3) Business method execution and data acquisition Reflective call method, dynamically execute method through Method.invoke(), pass in binding parameters.
[0085] Data collection processing, forced conversion of return value to List <map>Type, ensure the data format uniform.
[0086] Null bottom: if the return value is null, automatically replace the empty set to avoid the generation of Excel when the null pointer exception.
[0087] According to the configured export template information, the obtained data to be exported is filled into the export template information, and the process of generating the final export table file includes: The result set collected in the above two steps is taken as the incoming parameter of this step, and the data excel file is exported, wherein the parameter list is as follows: public static void createExcel( List<List<Map<String, Object>>>dataList, / / multiple Sheet data collection (each Sheet corresponds to a List <map>}); String filename, / / Export file's base name (without date and extension) List<Map<String, Object>>sheets, / / Sheet page basic configuration (name, order, etc.) List<List<Map<String, Object>>>heads, / / Multi-Sheet header configuration set (each Sheet corresponds to a header list) HttpServletResponse response, / / HTTP response object, used to output file stream.
[0088] Specifically includes: Step 1: Initialize Excel workbook.
[0089] (1) Get the total number of Sheet pages sheetCount according to the passed-in sheets parameter; (2) Parse the sheets configuration and extract the names of all Sheet pages to generate an ordered sheetList. (3) Create an XSSFWorkbook object as an Excel file container.
[0090] Step 2: Loop through each Sheet page.
[0091] (1) Get the header configuration Extract the header configuration head of the current Sheet page from heads, parse the header configuration, and generate an ordered: headNameList: List of table header display names (e.g.: ["order_no", "amount"]).
[0092] headIdList: List of table header field IDs (e.g.: ["order_no", "amount"]).
[0093] (2) Create Sheet page and table header Create a new Sheet page sheet according to the name in sheetList.
[0094] Create a table header row (row 0) and fill in the display names in headNameList.
[0095] (3) Fill in the data content Iterate through the data collection dataList.get(x) of the current Sheet page.
[0096] (4) Row creation rule: The 0th row is a table header, and the data starts from the 1st row. The 0th column of each row is a serial number (automatically generated i+1), and the subsequent columns are filled with data fields in the order of headIdList.
[0097] (5) Data assignment logic The field ID is obtained through headIdList.get(j), and the corresponding value is extracted from dataList. When the value is null, an empty string is automatically filled.
[0098] Step 3: Generate and output Excel file Set the HTTP response header, write the XSSFWorkbook to the response output stream, and close the workbook (wb.close()) and the output stream (out.close()) in turn.
[0099] In summary, the present embodiment uses table header configuration, stores field titles, mapping rules, and style definitions through the excel_meta configuration table, replaces hard coding, encapsulates general logic, abstracts general logic such as data conversion and file generation into a framework, and developers only need to focus on business data interfaces. New export functions can be implemented with only a small amount of code, or even without new code (reducing 90% of the code amount).
[0100] The present embodiment uses a dynamic template engine to dynamically generate table headers (such as column order and title name) based on JSON configuration, supports runtime adjustment, and can shorten the response time of dynamic configuration requirements to within 1 hour.
[0101] The present embodiment uses a standardized data interface to define a unified data export interface. Business systems can independently implement data acquisition logic or reference existing business logic interfaces to process data through java reflection. This avoids repeated development of business logic and separates export logic from business logic. When business interfaces are changed, the export module requires zero adaptation and modification, reducing the scope of failure impact and rejecting the introduction of irrelevant functions such as stream processing and cross-system transactions to ensure lightweight and easy-to-land solutions.
[0102] As shown in Table 1, the method provided by the present embodiment has high effectiveness.
[0103] Table 1
[0104] Embodiment Two A configuration table data export system for a query list page includes: The configuration module is configured to configure export template information in response to a configuration table data export request, and the configuration content includes a file name, sheet information, and a mapping relationship between a field and a header. The calling module is configured to call a unified export interface, input related parameters of an export file, judge whether the related parameters are valid, and if so, obtain a file name, a sheet set, and related fields. The reflection module is configured to use a reflection mechanism to obtain a business method parameter list through related parameters, dynamically input the parameters, assign the input parameters to the business method parameter list in sequence, and obtain data to be exported. The export module is configured to fill the obtained data to be exported into the export template information according to the configured export template information, and generate a final export table file.
[0105] The processes of the modules are described in the steps of the first embodiment, and will not be repeated here.
[0106] Embodiment three A computer readable storage medium for storing computer instructions, the computer instructions being executed by a processor to complete the steps in the method provided in the first embodiment.
[0107] Embodiment four An electronic device comprising a memory and a processor, and computer instructions stored on the memory and running on the processor, the computer instructions being executed by the processor to complete the steps in the method provided in the first embodiment.
[0108] Those skilled in the art will appreciate that embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, etc.) containing computer-usable program code. CD - ROM
[0109] The present application is described with reference to flowcharts and / or block diagrams according to the method, device (system), and computer program product of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the computer or other programmable data processing devices produce a device that implements the functions described in the flowcharts and / or block diagrams. Figure 1 apparatuses that implement the functions specified in the flowchart Figure 1
[0110] These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the flowchart Figure 1 apparatuses that implement the functions specified in the flowchart Figure 1
[0111] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions that are executed on the computer or other programmable apparatus provide steps for implementing the flowchart Figure 1 apparatuses that implement the functions specified in the flowchart Figure 1
[0112] The above description is only preferred embodiments of the present application and is not intended to limit the present application. The present application can be variously changed and modified by those skilled in the art without departing from the spirit and scope of the present application. Any modification, equivalent replacement, improvement, etc. made by those skilled in the art without departing from the spirit and scope of the present application should be included in the scope of the present application.< / map> < / map> < / map>
Claims
1. A method for exporting configurable tabular data from a query list page, characterized in that, Includes the following steps: In response to a configurable table data export request, configure the export template information, including the file name, sheet page information, and the mapping relationship between fields and table headers; Call the unified export interface, pass in the relevant parameters of the export file, check whether the relevant parameters are valid, and if valid, get the file name, the set of Sheet pages and relevant fields; By using reflection, the list of business method parameters is obtained through relevant parameters, the parameters are dynamically passed in, and the passed parameters are assigned to the list of business method parameters in order to obtain the data to be exported. Based on the configured export template information, the acquired data to be exported is filled into the export template information to generate the final export table file.
2. The method for exporting configurable table data from a query list page as described in claim 1, characterized in that, The exported template information includes a table file information table, a sheet page information table, and a table field information table.
3. The method for exporting configurable table data from a query list page as described in claim 2, characterized in that, The table file information table includes a primary key, a globally unique file identifier, and file naming rules; The Sheet information table includes a primary key, a unique identifier for the Sheet page, the display name of the Sheet page, the order of the Sheet pages, foreign keys, and the name of the core business interface. The table field information table includes the primary key, the original field name returned by the business interface, the table column display name, the display order of the fields in the table, and the foreign key; One globally unique file identifier corresponds to multiple unique identifiers for each sheet page, and one unique identifier for each sheet page corresponds to multiple original field names returned by business interfaces.
4. The method for exporting configurable table data from a query list page as described in claim 1, characterized in that, The process of calling the unified export interface and passing in the relevant parameters for the export file includes: calling the unified interface via URL, requiring the passing of a first parameter, a second parameter, and a third parameter. The first parameter represents the file stream written by the user after the method execution is completed, used to generate the corresponding result file; the second parameter is the data identifier to be exported, which corresponds to the globally unique file identifier in the table file information table; the third parameter is the type of the business method parameter list, and the number of elements in the business method parameter list must be consistent with the number of sheets in the corresponding exported table file, and all of them must be consistent with the required parameters of the corresponding business interface.
5. The method for exporting configurable table data from a query list page as described in claim 1, characterized in that, The process of determining whether the relevant parameters are valid includes: calling the file name retrieval logic to obtain the file name, the purpose of which is to name the exported file later; Call the logic to retrieve the Sheet page collection, obtain the corresponding Sheet pages, as well as the names and order of the Sheet pages, to prepare for subsequent data writing; Call the logic to get the fields of each sheet and obtain the corresponding field set.
6. The method for exporting configurable table data from a query list page as described in claim 1, characterized in that, During the process of dynamically passing in the parameters and assigning values to the business method parameter list in order, data set processing is performed, and the return value is forcibly converted to a predetermined type to ensure that the data format is consistent. If the return value is invalid, it will be automatically replaced with an empty collection to avoid null pointer exceptions when generating the table.
7. The method for exporting configurable table data from a query list page as described in claim 1, characterized in that, The process of filling the obtained data to be exported into the export template information and generating the final export table file includes: Get the total number of Sheet pages based on the input parameters; Parse the Sheet page configuration, extract the names of all Sheet pages, and generate an ordered list; Create a predefined object as a container for the table file; Get the table header configuration, parse the table header configuration, and generate an ordered list of table header display names and a list of table header field IDs; Create a sheet page and header; Iterate through the data set of the current Sheet page and populate it with data content; The table starts with row 0 as the header, and the data starts from row 1. The 0th column of each row is the sequence number. The data is processed sequentially and iterated. Subsequent columns are filled with data fields according to the order of the header list. Get the ID field, extract the corresponding value from the list of numbers, and automatically fill in an empty string if the value is invalid; Set the HTTP response headers, write the predefined object to the response output stream, and then close the workbook.
8. A configurable tabular data export system for a query list page, characterized in that, include: The configuration module is configured to respond to a configurable table data export request, configure the export template information, and the configuration content includes the file name, sheet page information, and the mapping relationship between fields and table headers; The calling module is configured to call a unified export interface, pass in the relevant parameters of the export file, determine whether the relevant parameters are valid, and if valid, obtain the file name, the set of Sheet pages, and relevant fields; The reflection module is configured to use reflection to obtain a list of business method parameters through relevant parameters, dynamically pass in the parameters, assign values to the list of business method parameters in order, and obtain the data to be exported. The export module is configured to fill the obtained data to be exported into the export template information according to the configured export template information, and generate the final export table file.
9. A computer-readable storage medium, characterized in that, Used to store computer instructions, which, when executed by a processor, perform the steps of the method as described in any one of claims 1-7.
10. An electronic device, characterized in that, It includes a memory and a processor, as well as computer instructions stored in the memory and running on the processor, which, when executed by the processor, perform the steps in the method as described in any one of claims 1-7.