File exporting method and device, equipment, medium and product

By using dual-template parsing technology, the structure and data logic in the file export process are separated, enabling dynamic and fully automated file generation. This solves the problem of high maintenance costs caused by the coupling of file style and data logic in existing technologies, and improves the system's flexibility and efficiency.

CN121636607APending Publication Date: 2026-03-10ZHOUPU DATA TECH NANJING CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-05
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

In existing file export methods, the file style and data logic are highly coupled, resulting in high maintenance costs and the need for manual definition of structure templates, which increases labor costs.

Method used

A dual-template parsing method is adopted, which achieves dynamic and fully automated file generation by separating structural templates and data templates. The structural template defines the data display style and the data template defines the data logic to generate the target file.

Benefits of technology

It improves the system's flexibility and efficiency, adapts to multiple data formats, reduces maintenance costs, and minimizes manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121636607A_ABST
    Figure CN121636607A_ABST
Patent Text Reader

Abstract

The invention discloses a file exporting method and device, equipment, a medium and a product, and relates to the technical field of data conversion and processing. Obtaining a file export request; analyzing the file export request to obtain a request parameter; the request parameters comprise data parameters and template parameters; searching a target structure template and a target data template from a template library based on the template parameters; determining a target structure and target data based on the data parameters, the target structure template, the target data template and a database; and rendering the target data based on the target structure to generate a target file. By adopting the technical scheme, the structure template and the data template are subjected to double-template analysis, the data are rendered based on the structure, the export file is generated, the flexibility of the system is improved by adopting the double-template design, the system can adapt to various data formats, and the problems that in the existing file export process, the structure definition needs to be highly coupled with data logic, and the export efficiency is high are solved. And the maintenance cost is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data conversion and processing technology, and in particular to a file export method, apparatus, device, medium, and product. Background Technology

[0002] For scenarios with large amounts of data, file export allows you to quickly find the data you need.

[0003] However, existing file export methods often involve storing file styles and data together. Although they can dynamically export Excel (Microsoft Excel) files, the style definitions and data logic in the files are highly coupled, resulting in high maintenance costs. Furthermore, the structural templates for different files need to be defined manually and backed up manually, leading to high labor costs.

[0004] Therefore, there is an urgent need for a file export method that can dynamically and automatically generate files, enabling the rapid export of Excel files. Summary of the Invention

[0005] This invention provides a file export method, apparatus, device, medium, and product that solves the problem of high maintenance costs caused by the high coupling between structural definition and data logic in existing file export processes. By performing dual-template parsing on structural templates and data templates, and rendering data based on the structure, an export file is generated. The dual-template design improves system flexibility and can adapt to various data formats.

[0006] According to one aspect of the present invention, a file export method is provided, comprising:

[0007] Get the file export request;

[0008] The file export request is parsed to obtain request parameters; the request parameters include data parameters and template parameters.

[0009] Based on the template parameters, the target structure template and target data template are searched from the template library;

[0010] The target structure and target data are determined based on the data parameters, the target structure template, the target data template, and the database.

[0011] The target data is rendered based on the target structure to generate a target file.

[0012] According to another aspect of the present invention, a file export apparatus is provided, comprising:

[0013] The retrieval module is used to retrieve file export requests;

[0014] The parsing module is used to parse the file export request to obtain request parameters; the request parameters include data parameters and template parameters.

[0015] The search module is used to search for target structure templates and target data templates from the template library based on the template parameters;

[0016] The determination module is used to determine the target structure and target data based on the data parameters, the target structure template, the target data template, and the database.

[0017] The rendering module is used to render the target data based on the target structure and generate a target file.

[0018] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0019] At least one processor; and

[0020] A memory communicatively connected to the at least one processor; wherein,

[0021] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the file export method according to any embodiment of the present invention.

[0022] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the file export method described in any embodiment of the present invention.

[0023] According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program that, when executed by a processor, implements the file export method according to any embodiment of the present invention.

[0024] The technical solution of this invention performs dual-template parsing on the structure template and the data template, and renders the data based on the structure to generate an export file. The dual-template design improves the system flexibility, can adapt to various data formats, and solves the problem of high maintenance costs caused by the high coupling between structure definition and data logic in the existing file export process.

[0025] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0026] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0027] Figure 1 This is a flowchart of a file export method provided according to an embodiment of the present invention;

[0028] Figure 2 This is a flowchart of a method for finding target structure templates and target data templates according to an embodiment of the present invention;

[0029] Figure 3 This is a flowchart of a file export method provided according to an embodiment of the present invention;

[0030] Figure 4 This is a schematic diagram of a file export device according to an embodiment of the present invention;

[0031] Figure 5 This is a schematic diagram of the structure of an electronic device that implements the file export method of this invention. Detailed Implementation

[0032] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0033] It should be noted that the terms "comprising" and "having" and any variations thereof in the specification, claims and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product or device.

[0034] Furthermore, it should be noted that the information collected in the technical solution of this invention is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of related data all comply with the relevant laws, regulations and standards of relevant countries and regions, necessary confidentiality measures have been taken, and public order and good morals are not violated. Corresponding operation entry points are provided for users to choose to authorize or refuse.

[0035] Figure 1 This invention provides a flowchart of a file export method according to an embodiment of the present invention. This embodiment is applicable to situations involving file export, particularly Excel files. The method can be executed by a file export device, which can be implemented in hardware and / or software and can be configured in a server. Figure 1 As shown, the method includes:

[0036] S110, Get file export request.

[0037] The file export request is a request instruction sent by the user to export an Excel file; the file export request carries query parameters such as the query time range or query conditions.

[0038] Specifically, the user sends a file export operation through the front-end interface or API (Application Programming Interface), and the server receives the file export operation as a file export request.

[0039] S120. Parse the file export request to obtain the request parameters; the request parameters include data parameters and template parameters.

[0040] Among them, the data parameters in the request parameters can be query parameters such as query time range or query conditions; the template parameters in the request parameters can be template ID (Identification) and template version number.

[0041] Specifically, the file export request is parsed to obtain the template ID and template version number corresponding to the template in this file export operation, as well as the query parameters such as the query time range or query conditions.

[0042] S130. Search for the target structure template and target data template from the template library based on the template parameters.

[0043] The template library stores at least one candidate structure template and at least one candidate data template. The structure template can be the style of an Excel file with an XML (Extensible Markup Language) structure. The data template can be a data rule template with JSON (JavaScript Object Notation) rules. The data rule template can be a data query rule. The target structure template is the candidate structure template corresponding to this file export request. The target data template is the candidate data template corresponding to this file export request.

[0044] Specifically, based on the template ID and template version number in the template parameters, the corresponding target structure template and target data template are found from the template ID and template version number corresponding to at least one candidate structure template and at least one candidate data template in the template library.

[0045] Optional, such as Figure 2 The method for finding target structure templates and target data templates, as shown, involves searching for target structure templates and target data templates from a template library based on template parameters, including:

[0046] S131. Based on the template identifier in the template parameters, search the template library for at least one corresponding candidate structure template and at least one candidate data template.

[0047] The template identifier can be a template ID.

[0048] Specifically, the template ID in the template parameters is used to search the template library for at least one candidate structure template and at least one candidate data template corresponding to the template ID. For example, if the template ID can be a sales report, then the report can have multiple versions according to actual needs, and there is at least one candidate structure template and candidate data template corresponding to a template ID.

[0049] S132. Determine if the template parameter contains a target version number.

[0050] The target version number is the template version specified in this file export request, which is used to specify the version of the template used in this file export.

[0051] Specifically, determine whether the template parameter in the request parameters parsed from this export request contains the target version number.

[0052] S133. If a target version number exists in the template parameters, then the target structure template and the target data template are determined from at least one candidate structure template and at least one candidate data template based on the target version number.

[0053] Specifically, if the template parameters contain a target version number, indicating that it is a version of the specified template, then the target structure template and target data template corresponding to the target version number are determined from at least one candidate structure template and at least one candidate data template, respectively.

[0054] In an optional embodiment of the present invention, after finding the structure template and the data template, a consistency check can be further performed on the structure version number corresponding to the found structure template and the data version number corresponding to the data template. The structure template and the data template that have been successfully checked are used as the target structure template and the target data template, thereby ensuring the consistency of the templates and improving the efficiency of subsequent export of Excel files.

[0055] S134. If the template parameter does not have a target version number, then the candidate structure template and candidate data template with the highest version number will be used as the target structure template and target data template.

[0056] Specifically, if the template parameter does not have a target version number, the version number call counts of all candidate structure templates and candidate data templates under that template ID are compared, and the candidate structure template and candidate data template with the most version number call counts are used as the target structure template and target data template.

[0057] In an optional embodiment of the present invention, the candidate structure version number and candidate data version number corresponding to all candidate structure templates and candidate data templates under template ID can be compared, and the candidate structure template and candidate data template corresponding to the latest candidate structure version number and candidate data version number can be used as the target structure template and target data template.

[0058] Understandably, template selection is based on the template IDs, version numbers, and corresponding post-structure and data templates stored in the template library. This enables a version control system that allows multiple versions to be executed in parallel, ensuring the accuracy and usability of Excel file exports. Versions can be specified to be suitable for various data styles, improving the efficiency of exporting data to Excel files.

[0059] Optionally, the template library contains at least one template identifier, candidate structure template, candidate data template, and candidate version number; there is at least one candidate version number under the same template identifier; the candidate structure template, candidate data template, and candidate version number are related.

[0060] The template identifier is the template type and can be uniquely identified by the template ID. There can be at least one template version under the same template identifier. Different template versions are distinguished by version number. A candidate version number can have corresponding candidate structure templates and candidate data templates.

[0061] Specifically, the template library pre-stores at least one template identifier, and under the same template identifier there can be at least one template version number. The same template version number corresponds to a structure template and a data template.

[0062] It is understandable that setting template identifiers and template version numbers can be used to version control structure templates and data templates, ensuring that the appropriate template can be selected for file export. Template version numbers and template identifiers can also be used to control the dual template format of structure templates and data templates. Setting template version numbers can also enable historical data traceability of template versions.

[0063] Optional methods for updating the template library include:

[0064] In response to the upload operation on the interactive interface, the initial structure template and the initial data template are obtained; the initial structure template and the initial data template are each associated with a corresponding template identifier;

[0065] Template matching is performed in the template library based on template identifiers;

[0066] If the match fails, a target version number is randomly generated, and the template identifier, target version number, initial structure template, and initial data template are associated and stored in the template library.

[0067] If a match is found, the candidate version number is determined.

[0068] The counting mechanism based on the candidate version number determines the task count corresponding to the candidate version number; the counting mechanism is to decrement the task count by one for each template call completed.

[0069] If the task count reaches zero, a target version number is generated based on the candidate version number. The target version number, initial structure template, and initial data template are then used to replace the candidate version number, candidate structure template, and candidate data template, respectively, and stored in the template library.

[0070] Among them, the initial structure template and the initial data template are pre-set templates; the initial structure template uses an XML style template to define the data display structure; the initial data template uses a JSON data rule template to define the data processing logic; the initial version number is the version number corresponding to the initial structure template and the initial data template; the task count is the number of times the version number in the template library is called, which is used to indicate whether the structure template and data template corresponding to the version number are being called.

[0071] Specifically, in response to the upload operation on the interactive interface, the system obtains the initial structure template and the initial data template. Each initial structure template and initial data template is associated with a corresponding template identifier. Template matching is performed in the template library based on the template identifier. If the match fails, it indicates that a template for the current file output type does not exist. A target version number is randomly generated as the major version number, and the template identifier, target version number, initial structure template, and initial data template are associated and stored in the template library. If the match succeeds, it indicates that an older version of the file output type exists in the template library, which can be either the major or minor version. The latest version number is used as the candidate version number under this template identifier. The task count corresponding to the candidate version number is determined based on the candidate version number's counting mechanism, indicating whether the structure template and data template corresponding to that candidate version number are being called. The counting mechanism decrements the task count by one for each completed template call. If the task count reaches zero, it indicates that the structure template and data template corresponding to that candidate version number do not need to be called and are in a resting state. A target version number is generated based on the candidate version number, and the target version number, initial structure template, and initial data template replace the candidate version number, candidate structure template, and candidate data template respectively, storing them in the template library.

[0072] In one optional embodiment of the present invention, each effective candidate version number in the template library has a corresponding counting mechanism, which counts based on template calls. If there are three template call requests corresponding to the candidate version number at the same time, the count is 3. After each template call to perform file export, the count is decremented by one. If the current candidate version number count is 2, it indicates that there are still two file export tasks in progress. Until the candidate version number count is 0, it indicates that the structure template and data template corresponding to the candidate version number have no file export tasks and other operations can be performed.

[0073] In an optional embodiment of the present invention, when the task count corresponding to the candidate version number is not zero, the initial structure template and the initial data template can be pre-stored in an independent storage area. After the task count is zeroed, the initial structure template and the initial data template can be updated to the candidate structure template and the candidate data template.

[0074] In an optional embodiment of the present invention, the template library's counting mechanism can detect the template status by setting a listening mechanism. Specifically, the template status is updated by listening to the task execution status of the templates. For example, file listening is performed on candidate structure templates and candidate data templates in the template library to monitor the usage status of the templates in real time. If a candidate structure template or candidate data template is performing a file export task, its status is "in use". A task count is set according to the number of file export tasks. After each file export task is completed, the task count of the candidate structure template and candidate data template is decremented by 1 until all file export tasks are completed. At this time, the task count is 0, and the template status of the candidate structure template and candidate data template is "idle". When the template status is "idle" and the task count is zero, the template version can be updated. By setting a file listening mechanism to control the template status and update timing, it is ensured that during the version update process, the old version continues to execute existing tasks, and the new version iteration is triggered only after its use is completed. This effectively avoids the risk of business interruption caused by forced restart and improves system availability.

[0075] In an optional embodiment of the present invention, after the candidate structure template and candidate data template are updated, the previous version of the candidate structure template and candidate data template is locked and a retention time is set. Specifically, according to the file monitoring mechanism, the template status of the old version of the candidate structure template and candidate data template is set to "disabled"; and a timer is set. If the retention time exceeds a preset time threshold, an old version cleanup operation is triggered to remove the old version of the candidate structure template and candidate data template from memory, thereby avoiding the long-term occupation of template library resources and realizing full lifecycle management of each candidate structure template and candidate data template in the template library, ensuring effective management of each version in the template library.

[0076] Understandably, the reference counting mechanism manages the template version lifecycle, automatically reclaiming and updating the version when references reach zero. This facilitates tracing historical versions, ensures that old and new versions can coexist, and allows version updates to be completed without restarting the application software and without affecting the export task.

[0077] S140. Determine the target structure and target data based on data parameters, target structure template, target data template, and database.

[0078] The database stores the data to be queried; the target structure is the file structure style corresponding to the current file export request; and the target data is the file data in the current file export request.

[0079] Specifically, the target structure template is parsed to obtain the corresponding target structure; and data query rules are determined based on the target data template and data parameters. Database queries are then executed based on the data query rules to obtain the target data.

[0080] S150. Render the target data based on the target structure to generate the target file.

[0081] The target file is an Excel file.

[0082] Specifically, the target data is merged and rendered according to the file structure style in the target structure. For example, the JSON structure in the target data field can be matched and mapped to obtain the data of each cell in the Excel file, and the cell style in the target structure can be used to render the cells to generate the Excel file.

[0083] This invention provides an embodiment that obtains a file export request; parses the file export request to obtain request parameters, including data parameters and template parameters; searches for a target structure template and a target data template in a template library based on the template parameters; determines the target structure and target data based on the data parameters, the target structure template, the target data template, and a database; and renders the target data based on the target structure to generate a target file. This technical solution, by parsing both the structure template and the data template and rendering the data based on the structure to generate the exported file, improves system flexibility through a dual-template design, adapting to various data formats and solving the problem of high maintenance costs caused by the high coupling between structure definition and data logic in existing file export processes.

[0084] Figure 3 This is a flowchart of a file export method according to an embodiment of the present invention. Based on the above embodiments, this embodiment supplements the method for determining the target structure and target data. It should be noted that for parts not detailed in this embodiment, please refer to the relevant descriptions in other embodiments. For example... Figure 3 As shown, the method includes:

[0085] S210, Obtain file export request.

[0086] S220. Parse the file export request to obtain the request parameters; the request parameters include data parameters and template parameters.

[0087] S230. Search for the target structure template and target data template from the template library based on the template parameters.

[0088] S240. Parse the target structure template to obtain the style tree structure.

[0089] The style tree structure is a tree structure built from the nodes and their corresponding node attributes in the corresponding XML style structure template.

[0090] Specifically, DOM4J (Document for Java) is used to parse the target structure template. Based on the structure in the target structure template and the styles in the corresponding columns, a tree structure is constructed. For example, the XML style format of the target structure template includes the table name " <sheet name="销售报表" default-style="normalStyle">", and the corresponding table name structure" <style name="headerStyle" font="微软雅黑" size="12" color="#FFFFFF" bgcolor="#4472C4" bold="true">< / style> ", indicating that the table is a sales report, and the title style in the table style, which includes the font as Microsoft YaHei, the font size as 12, the font color, the background color, and the line; each column in its Excel file is represented as "columns", and each column has its corresponding column name and the style of each cell in the column, such as "<column name = "orderId" label = "Order Number" width = "15" style = "normalStyle" dataType data type = "string string" / >", indicating that the column name is Order Number; the cell structure style can be represented by the data type, string, and width; then parse the XML structure template through DOM4J to obtain the style tree structure.

[0091] S250. Extract the nodes and node attributes in the style tree structure to obtain the target structure; the node is a column node; the node attribute is the column style corresponding to the column node.

[0092] Among them, the node can be the "columns" column; the node attribute can be the style structure corresponding to each column.

[0093] Specifically, the "styles" node in the style tree structure can be preferentially extracted to generate a CellStyle (CellStylePool, cell style object pool) object pool, and the "columns" node is extracted, and the node description corresponding to "columns" is parsed to obtain the column style corresponding to this column as the data type, format, and style; and the column node and the node attribute corresponding to the column node are created and stored as a ColumnDefinition object list (Column Definition Object List).

[0094] It can be understood that by parsing the XML file and extracting the column nodes therein, and parsing the column styles corresponding to the column nodes, it is convenient to directly render the styles of the data in the cells of this column later, improving the applicability of the data style structure.

[0095] S260. Map the data parameters to the target data template to obtain the target query template.

[0096] Among them, the target query template can be a data query rule in JSON structure, which can include the data query range and the data query date.

[0097] Specifically, the query time range and query conditions in the data parameters are mapped to the target data template to obtain the query template corresponding to the query rules of this file export request. For example, the data source used by the query template is "dataSource"; the query range in its configuration can be "SELECT order_id as orderId,product_name asproductName", which indicates that order_id is the order number and product name; the query time range in its configuration can be "amount FROM sales WHERE date BETWEEN${startDate}AND${endDate}", which indicates that the queried data also includes the query date of the amount; the time parameters in its configuration can be the start date and end date; the style of the post-processor required for the queried data can be the operation field and operation steps; and the footer style in the configuration.

[0098] S270. Parse the target query template to obtain the data query method.

[0099] The data query method can be a data query rule, which may include query rules and data processing rules.

[0100] Specifically, Jackson can be used to parse the target query template under the JSON structure and obtain the data query method based on the parsed configuration and query rules.

[0101] Optionally, the target query template is parsed to obtain a data query method, including:

[0102] The target query template is parsed to generate a data rule object model;

[0103] Parse the first key field in the data rule object model to generate a data query configuration;

[0104] The second key field in the data rule object model is parsed to obtain the data processing chain;

[0105] Parse the footer configuration in the data rule object model to obtain the footer style;

[0106] Data query configuration, data processing chain and footer style are used as data query methods.

[0107] The data rule object model is a text-described data rule, including configuration parameter rules, data processing rules and format rules; the first key can be the "type" field, which indicates the configuration data for data query; the second key can be the "postProcessors" field, which indicates the processing operation performed on the queried data; the footer configuration can be a footer style, indicated by the "footer" field.

[0108] Specifically, Jackson can be used to parse the target query template to generate a data rule object model; the first key field "type" in the data rule object model is parsed to generate a data query configuration, which may include parsing SQL and parameter binding rules to obtain database query rules, obtaining API call rules by configuring endpoint URLs and request parameters, and obtaining the data source corresponding to the query data by configuring the configuration file path and parsing the rules; and the second key field "postProcessors" in the data rule object model is parsed to obtain the data processing chain, such as data processing strategies: summary, average and other statistical calculation processing, data format conversion processing, and data validity verification processing; the footer configuration in the data rule object model is parsed to obtain the footer style, such as the style structure corresponding to each cell; and the data query configuration, data processing chain and footer style are used as the data query method.

[0109] S280. Perform query processing on the database based on the data query method to obtain the target data.

[0110] Wherein, the database is the data source configured in the data query method.

[0111] Specifically, the query data source corresponding to this file export request is found in the database according to the data query method, and the database is queried based on the data query configuration and data processing chain in the data query method to obtain the target data.

[0112] S290. Render the target data based on the target structure to generate a target file.

[0113] Optionally, rendering the target data based on the target structure to generate a target file includes:

[0114] Perform field matching on the target structure and target data to obtain the matching fields;

[0115] Based on the matching field, the target data is mapped to each node of the target structure to obtain node data;

[0116] The node data is rendered based on the node parameters in the target structure to generate the target file.

[0117] The field matching can be the matching of the "column name" node in the target structure and the "order_id" in the target data; the node data is the data retrieved from the "order_id" corresponding to the "column name" in the target structure.

[0118] Specifically, according to the target structure<column name="orderId"> The definition maps the field structure `order_id` in the target data to the `column` column, obtaining the node data corresponding to each `column` column node. It then binds the `CellStyle` object in the target structure to the data cell according to the node attributes corresponding to each node, and renders the node data with styles through the node attributes, generating an Excel file containing each query data after style structure processing.

[0119] In an optional embodiment of the present invention, the target structure also includes placeholders such as ${lastRow} in the XML template, which are marked as runtime replacement variables. During rendering, they are used to replace the footer formula configured in the footer of the target data; for example, if the footer formula is SUM(C2:C${lastRow}), it is replaced with the actual line number.

[0120] It is understood that the setting structure in<column name="orderId"> The system merges and maps the order_id data, and renders it based on the style structure corresponding to each column name. It uses XML style templates to define the data display structure and JSON data templates to define the data processing logic. The two work together to improve the system's flexibility and adapt to various data formats.

[0121] The embodiments of the present invention use dual templates, such as an XML template and a JSON data template, for collaborative display. The XML style template and the JSON data template are physically separated, supporting dynamic column generation, which facilitates maintenance and improves the flexibility of exporting Excel files.

[0122] Figure 4 is a schematic structural diagram of a file export device provided by an embodiment of the present invention. The embodiment of the present invention is applicable to the situation of exporting files, especially applicable to the situation of exporting Excel files. This method can be executed by a file export device, which can be implemented in the form of hardware and / or software, and the file export device can be configured in a server. As shown in Figure 4, the file export device 300 includes an acquisition module 310, an analysis module 320, a search module 330, a determination module 340, and a rendering module 350:

[0123] The acquisition module 310 is used to acquire a file export request;

[0124] The analysis module 320 is used to analyze the file export request to obtain request parameters; the request parameters include data parameters and template parameters;

[0125] The search module 330 is used to search for a target structure template and a target data template from a template library based on the template parameters;

[0126] The determination module 340 is used to determine a target structure and target data based on the data parameters, the target structure template, the target data template, and a database;

[0127] The rendering module 350 is used to render the target data based on the target structure to generate a target file.

[0128] In the embodiment of the present invention, a file export request is acquired; the file export request is analyzed to obtain request parameters; the request parameters include data parameters and template parameters; a target structure template and a target data template are searched from a template library based on the template parameters; a target structure and target data are determined based on the data parameters, the target structure template, the target data template, and a database; the target data is rendered based on the target structure to generate a target file. Through the above technical solution, by performing double-template parsing on the structure template and the data template, and rendering the data based on the structure to generate an export file, the double-template design is adopted to improve the flexibility of the system, which can adapt to various data formats, and solve the problem of high maintenance cost caused by the high coupling of structure definition and data logic in the existing file export process.

[0129] Optionally, the template library contains at least one template identifier, candidate structure template, candidate data template and candidate version number; there is at least one candidate version number under the same template identifier; the candidate structure template, candidate data template and candidate version number are associated.

[0130] Optionally, the file export device 300 further includes an update module, which is used to obtain an initial structure template and an initial data template in response to the upload operation of the interactive interface; the initial structure template and the initial data template are respectively associated with corresponding template identifiers;

[0131] Template matching is performed in the template library based on the template identifier;

[0132] If the matching fails, a target version number is randomly generated, and the template identifier, target version number, initial structure template and initial data template are associated and stored in the template library;

[0133] If the match is successful, the candidate version number is determined;

[0134] The task count corresponding to the candidate version number is determined based on the counting mechanism of the candidate version number; the counting mechanism is that the task count is decremented by one when a template call is completed;

[0135] If the task count reaches zero, the target version number is generated based on the candidate version number, and the target version number, the initial structure template, and the initial data template are used to replace the candidate version number, the candidate structure template, and the candidate data template, respectively, and stored in the template library.

[0136] Optionally, the search module 330 is further configured to search for at least one candidate structure template and at least one candidate data template from the template library based on the template identifier in the template parameters;

[0137] Determine whether the template parameter contains a target version number;

[0138] If a target version number exists in the template parameters, the target structure template and the target data template are determined from at least one candidate structure template and at least one candidate data template based on the target version number;

[0139] If the template parameter does not have a target version number, then the candidate structure template and candidate data template with the highest version number are used as the target structure template and target data template.

[0140] Optionally, the determining module 340 includes a structure parsing unit, an extraction unit, a mapping unit, a data parsing unit, and a query unit;

[0141] The structure parsing unit is used to parse the target structure template to obtain the style tree structure;

[0142] The extraction unit is used to extract nodes and node attributes from the style tree structure to obtain the target structure; the nodes are column nodes; the node attributes are the column styles corresponding to the column nodes;

[0143] The mapping unit is used to map data parameters to a target data template to obtain a target query template;

[0144] The data parsing unit is used to parse the target query template to obtain the data query method;

[0145] The query unit is used to perform query processing on the database based on the data query method to obtain the target data.

[0146] Optionally, the data parsing unit is also used to parse the target query template and generate a data rule object model;

[0147] Parse the first key field in the data rule object model to generate a data query configuration;

[0148] The second key field in the data rule object model is parsed to obtain the data processing chain;

[0149] Parse the footer configuration in the data rule object model to obtain the footer style;

[0150] Data query configuration, data processing chain and footer style are used as data query methods.

[0151] Optionally, the rendering module 350 is also used to perform field matching on the target structure and target data to obtain the matching fields;

[0152] Based on the matching field, the target data is mapped to each node of the target structure to obtain node data;

[0153] The node data is rendered based on the node parameters in the target structure to generate the target file.

[0154] The file export device provided in the embodiments of the present invention can execute the file export method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0155] According to an embodiment of the present invention, the present invention also provides an electronic device, a readable storage medium, and a computer program product.

[0156] Figure 5 shows a schematic structural diagram of an electronic device 10 that can be used to implement embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, a personal digital assistant, a cellular phone, a smart phone, a wearable device (such as a helmet, glasses, a watch, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0157] As shown in Figure 5, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. Among them, the memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.

[0158] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0159] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as file export methods.

[0160] In some embodiments, the file export method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the file export method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the file export method by any other suitable means (e.g., by means of firmware).

[0161] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0162] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The computer programs may be executed entirely on the machine, partially on the machine, or as a standalone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0163] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0164] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0165] The systems and technologies described herein can be implemented in computing systems that include back-end components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include front-end components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0166] A computing system may include a client and a server. The client and server are generally located far apart from each other and typically interact via a communication network.A client-server relationship is established by computer programs running on corresponding computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the shortcomings of traditional physical hosts and dedicated virtual services, such as high management difficulty and weak business scalability.

[0167] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and no limitation is imposed herein.

[0168] The above specific embodiments do not constitute a limitation on the scope of protection of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.< / sheet>

Claims

1. A file export method characterized by, The method comprises the following steps: obtaining a file export request; parsing the file export request to obtain request parameters; the request parameters comprise data parameters and template parameters; based on the template parameters, searching for a target structure template and a target data template from a template library; based on the data parameters, the target structure template, the target data template and a database, determining a target structure and target data; based on the target structure, rendering the target data to generate a target file.

2. The method of claim 1, wherein, The template library contains at least one template identifier, candidate structure template, candidate data template and candidate version number; there are at least one candidate version number under the same template identifier; the candidate structure template, the candidate data template and the candidate version number are in an associated relationship.

3. The method according to claim 1 or 2, characterized in that, The updating method of the template library comprises the following steps: in response to the uploading operation of the interactive interface, obtaining an initial structure template and an initial data template; the initial structure template and the initial data template are respectively associated with a corresponding template identifier; based on the template identifier, performing template matching in the template library; if the matching fails, a target version number is randomly generated, and the template identifier, the target version number, the initial structure template and the initial data template are associated and stored in the template library; if the matching is successful, the matched candidate version number is determined; based on the counting mechanism of the candidate version number, the task count corresponding to the candidate version number is determined; the counting mechanism is that the task count is reduced by one for each template call; if the task count is zero, a target version number is generated based on the candidate version number, and the target version number, the initial structure template and the initial data template are respectively replaced by the candidate version number, the candidate structure template and the candidate data template, and stored in the template library.

4. The method of claim 1, wherein, The method comprises the following steps: based on the template identifier in the template parameters, searching for at least one candidate structure template and at least one candidate data template from the template library; determining whether the template parameters contain a target version number; if the template parameters contain the target version number, based on the target version number, determining a target structure template and a target data template from the at least one candidate structure template and the at least one candidate data template respectively; if the template parameters do not contain the target version number, the candidate structure template and the candidate data template with the highest version number are used as the target structure template and the target data template.

5. The method of claim 1, wherein, The method comprises the following steps: parsing the target structure template to obtain a style tree structure; extracting nodes and node attributes in the style tree structure to obtain a target structure; the nodes are column nodes; the node attributes are column styles corresponding to the column nodes; mapping the data parameters to the target data template to obtain a target query template; parsing the target query template to obtain a data query method; based on the data query method, performing query processing on the database to obtain target data.

6. The method of claim 5, wherein, The method comprises the following steps: The target query template is parsed to generate a data rule object model; The first key field in the data rule object model is parsed to generate a data query configuration; The second key field in the data rule object model is parsed to obtain a data processing chain; The footer configuration in the data rule object model is parsed to obtain a footer style; The data query configuration, the data processing chain and the footer style are used as a data query method.

7. The method of claim 1, wherein, The target data is rendered based on the target structure to generate a target file, including: The target data is mapped to each node of the target structure based on the matching field to obtain node data; The node data is rendered based on the node parameters in the target structure to generate a target file. It includes:

8. A file export apparatus characterized by comprising: The acquisition module is used for acquiring a file export request; The analysis module is used for analyzing the file export request to obtain request parameters; The request parameters include data parameters and template parameters; The search module is used for searching a target structure template and a target data template from a template library based on the template parameters; The determination module is used for determining a target structure and target data based on the data parameters, the target structure template, the target data template and a database; The rendering module is used for rendering the target data based on the target structure to generate a target file. The electronic device includes:

9. An electronic device, comprising: At least one processor; and The memory is in communication connection with the at least one processor; wherein The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the file export method in any one of claims 1-7. The computer readable storage medium stores computer instructions, and the computer instructions are used to enable the processor to execute the file export method in any one of claims 1-7 when executed.

10. A computer-readable storage medium, characterized in that, The computer program product includes a computer program, and the computer program is executed by the processor to implement the file export method according to any one of claims 1-7.

11. A computer program product, characterised in that, ​

Citation Information

Patent Citations

  • Excel data importing method and device, electronic equipment and storage medium

    CN115080651A

  • EPG (Electronic Program Guide) data importing method, device and equipment and computer readable storage medium

    CN117271451A

  • Method, device and equipment for processing and exporting report data with large data volume and medium

    CN120409438A

  • Excel file exporting method and system based on Java language

    CN120930613A

  • Complex data dynamic export method based on templated configuration, computer program product and system

    CN121009871A