Method, device, computer equipment and storage medium for exporting electronic spreadsheet files
Through template mode and parameter name mapping, structured query language is dynamically generated, which solves the flexibility and performance issues when exporting spreadsheet files and realizes efficient data export and system optimization.
Patent Information
- Application Number
- CN202010348340.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-28
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2040-04-28
AI Technical Summary
The existing technology has problems such as poor flexibility, low reusability and low performance when exporting spreadsheet files. In particular, when the amount of data is large, the system response speed is slow and the system pressure is high.
Using the template mode, we can create query templates and dynamically generate structured query language through the mapping relationship between parameter names and condition names. By combining encryption and level marking mechanisms, we can optimize the data acquisition process and avoid repeated writing of export functions and data redundancy.
It improves the system's response speed, reduces system pressure, improves development efficiency and flexibility, and prevents SQL injection and data redundancy.
Smart Images

Figure CN111680477B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data technology, and in particular to a method, apparatus, computer equipment, and storage medium for exporting spreadsheet files. Background Art
[0002] Exporting Excel files is a common management system feature. Currently, there are two common implementation methods: First, a separate system is developed for specific business scenarios. This system retrieves data corresponding to specified fields from the database, generates an Excel tool, traverses the data and populates it into an Excel sheet, and then calls a flow to export the Excel file. However, the exported data is dynamic, and each time a new field is added, it must be added to each step. This involves significant system changes and numerous details, making it easy to miss anything. Furthermore, new business needs that require exporting different data require a new system, resulting in low reusability and limited flexibility. Second, all required data is backed up in a designated table. A page lists all fields, allowing users to select the data they need. The system then records each user-specified field to be exported, queries the data, and exports the Excel file. However, placing all data in a single table, with many fields and a large data volume, results in long export times and poor performance. The excessive number of redundant fields makes it difficult to export real-time data. Summary of the Invention
[0003] The purpose of the embodiments of the present application is to provide a method, apparatus, computer equipment and storage medium for exporting spreadsheet files, thereby improving the response speed of the system and reducing the system pressure.
[0004] In order to solve the above technical problems, the embodiment of the present application provides a method for exporting a spreadsheet file, which adopts the following technical solution:
[0005] A method for exporting a spreadsheet file comprises the following steps:
[0006] Creating a query template, the query template including a table header, a title attribute, a structured query language to be executed, a spreadsheet name, query parameters, and the number of data, and mapping the table header to the title attribute one-to-one; the structured query language to be executed including a query condition and an execution statement, the query condition including a condition name, the query parameter including a parameter name, and mapping the condition name to the parameter name one-to-one;
[0007] When a query instruction is received, the electronic form name, the number of data, the query parameters, the title attributes and the table header corresponding to the title attributes in the query template are read;
[0008] According to the mapping relationship between the parameter name in the query parameter and the condition name, the obtained parameter name is used to replace the corresponding condition name in the structured query language to be executed, so as to complete the assembly of the structured query language to be executed;
[0009] Executing the structured query language to be executed to obtain business data from the database; and
[0010] Generate and output a spreadsheet based on the obtained header, business data, spreadsheet name and data quantity.
[0011] Furthermore, the step of reading the electronic table name, data quantity, query parameters, title attributes and table headers corresponding to the title attributes in the query template includes:
[0012] Pre-set one-to-one corresponding query codes for the parameter names of the query parameters;
[0013] If the received query instruction carries a query code, determining and obtaining a parameter name of a corresponding query parameter in the query template according to the query code;
[0014] If the received query instruction does not carry a preset query code, then obtaining parameter names of all query parameters;
[0015] The electronic table name, data quantity, title attributes, and table header corresponding to the title attributes in the query template are read.
[0016] Furthermore, after the step of creating the query template, the method further includes:
[0017] Encrypting the query template using a preset key to generate ciphertext, and storing the ciphertext in a database;
[0018] The step of reading the electronic form name, data quantity, query parameters, title attributes and table headers corresponding to the title attributes in the query template when a query instruction is received includes:
[0019] When receiving a query instruction carrying a key, obtaining the key carried in the query instruction, decrypting the ciphertext using the key, and obtaining the query template;
[0020] The electronic table name, data quantity, query parameters, title attributes and table headers corresponding to the title attributes in the query template are read.
[0021] Furthermore, after the step of mapping the condition names to the parameter names one by one, the method further includes: setting the query condition in the query template in the form of a placeholder.
[0022] Furthermore, the step of executing the structured query language to be executed and obtaining business data from the database includes:
[0023] Obtaining the number of data in the query template, and determining the number of business data to be obtained from the database according to the structured query language to be executed;
[0024] comparing the amount of the business data with the number of data;
[0025] If the amount of the business data is less than or equal to the number of data, executing the to-be-executed structured query language to obtain the business data from the database;
[0026] If the amount of the business data is greater than the number of data, the structured query language to be executed is executed to obtain business data from the database in multiple times, wherein the amount of business data obtained each time is less than or equal to the number of data.
[0027] Furthermore, the step of executing the structured query language to be executed and obtaining business data from the database includes:
[0028] Obtaining the number of data in the query template, and determining the number of business data to be obtained from the database according to the structured query language to be executed;
[0029] comparing the amount of the business data with the number of data;
[0030] If the amount of the business data is greater than the number of data, identifying the level tag pre-applied to the parameter name, wherein the level tag includes at least a first level and a second level;
[0031] Delete and back up the parameter names marked with levels other than the first level, and send the deleted parameter names to the designated person via email;
[0032] All parameter names in the structured query language to be executed are replaced with the parameter names marked with the first-level level, and the structured query language to be executed is executed to obtain business data from the database.
[0033] In order to solve the above technical problems, the embodiment of the present application further provides a device for exporting a spreadsheet file, which adopts the following technical solution:
[0034] A device for exporting a spreadsheet file, comprising:
[0035] a creation module, configured to create a query template, the query template including a table header, a title attribute, a structured query language to be executed, a spreadsheet name, query parameters, and a data quantity, and mapping the table header to the title attribute one-to-one; the structured query language to be executed including a query condition and an execution statement, the query condition including a condition name, the query parameter including a parameter name, and mapping the condition name to the parameter name one-to-one;
[0036] A reading module, configured to read the electronic form name, data quantity, query parameters, title attributes, and table headers corresponding to the title attributes in the query template when a query instruction is received;
[0037] a replacement module, configured to replace the corresponding condition name in the structured query language to be executed with the acquired parameter name according to the mapping relationship between the parameter name in the query parameter and the condition name, so as to complete the assembly of the structured query language to be executed;
[0038] An execution module, configured to execute the structured query language to be executed and obtain business data from a database; and
[0039] The generating module is used to generate and output the electronic form according to the obtained table header, business data, electronic form name and data quantity.
[0040] Furthermore, the reading module includes a setting submodule, an acquisition submodule and a reading submodule;
[0041] The setting submodule is used to pre-set a one-to-one corresponding query code for the parameter name of the query parameter;
[0042] The acquisition submodule is configured to determine and acquire the parameter names of the corresponding query parameters in the query template according to the query code when the received query instruction carries a query code, and acquire the parameter names of all query parameters when the received query instruction does not carry a preset query code;
[0043] The reading submodule is used to read the electronic form name, data quantity, title attributes, and table headers corresponding to the title attributes in the query template.
[0044] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0045] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned method for exporting a spreadsheet file when executing the computer program.
[0046] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0047] A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method for exporting a spreadsheet file.
[0048] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0049] This application introduces a template mode, first defining the template, setting the rules, reading the template information according to the set rules, and completing the export of the spreadsheet. Among them, in the process of parsing the template, by parsing the parameter name of the query parameter, according to the mapping relationship, using the parameter name to replace the condition name in the database execution statement, the assembled database execution statement is obtained, and the database execution statement is executed to obtain the required data value from the database, avoiding the need to rewrite a set of export functions every time different data values are obtained, reducing development costs and improving efficiency. At the same time, when the system is running, the parameter name can also be dynamically modified without interfering with the execution of the database execution statement. In addition, the system obtains the corresponding data value according to the parameter name, without the need to export all the data values in the database at one time, avoiding data redundancy, improving the response speed of the system, and reducing the pressure on the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the solutions in this application, a brief introduction will be given below to the drawings required for use in the description of the embodiments of this application. Obviously, the drawings described below are some embodiments of this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0051] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0052] Figure 2 A flowchart of an embodiment of a method for exporting a spreadsheet file according to the present application;
[0053] Figure 3 is a structural diagram of an embodiment of a device for exporting a spreadsheet file according to the present application;
[0054] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application.
[0055] Figure numerals: 200, computer device; 201, memory; 202, processor; 203, network interface; 300, device for exporting spreadsheet file; 301, creation module; 302, reading module; 303, replacement module; 304, execution module; 305, generation module. DETAILED DESCRIPTION
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meanings as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of the application are for the purpose of describing specific embodiments only and are not intended to limit this application. The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0057] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0058] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0059] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. Network 104 is a medium for providing communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0060] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0061] Terminal devices 101, 102, and 103 can be various electronic devices with display screens and support web browsing, including but not limited to smartphones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV), laptop computers, desktop computers, etc.
[0062] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0063] It should be noted that the method for exporting a spreadsheet file provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the device for exporting a spreadsheet file is generally set in the server / terminal device.
[0064] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0065] Continue to refer Figure 2 , shows a flow chart of an embodiment of a method for exporting a spreadsheet file according to the present application. The method for exporting a spreadsheet file comprises the following steps:
[0066] S1: Create a query template, which includes a table header, title attributes, a structured query language to be executed, a spreadsheet name, query parameters, and the number of data, and the table header and the title attributes are mapped one-to-one. The structured query language to be executed includes query conditions and execution statements, the query conditions include condition names, and the query parameters include parameter names, and the condition names are mapped one-to-one with the parameter names.
[0067] In this embodiment, specifically, when writing the code, the query template includes the following five parts:
[0068] exportModels: table header and title attributes; sqlModels: structured query language to be executed; sheetName: Excel sheet name; queryParams: query parameters; countNum: number of data items. For example, the code is: "exportModels":[{"filedName":"id","headerName":"project_id"}]; where "filedName":"id" is the title attribute and "headerName":"project_id" is the table header. By introducing the template pattern, pre-defined templates are conveniently called when needed.
[0069] Wherein, in step S1, that is, after the step of mapping the condition names to the parameter names one by one, it includes: setting the query condition in the query template in the form of a placeholder.
[0070] In this embodiment, the query conditions exist in the query template in the form of placeholders, which prevents SQL injection. That is, when the structured query language to be executed is subsequently executed, it can be ensured that the executed structured query language to be executed has not been tampered with through SQL injection, eliminating some security risks.
[0071] S2: When a query instruction is received, the electronic table name, the number of data, the query parameters, the title attributes and the table header corresponding to the title attributes in the query template are read.
[0072] In this embodiment, the header and title attributes are pre-filled in the template and can be modified according to actual needs. Because the header and title attributes have a one-to-one correspondence, the computer first identifies the title attributes and then locates the header based on the title attributes. The spreadsheet name and number of data are read to complete the subsequently generated spreadsheet.
[0073] Specifically, in step S2, the step of reading the electronic table name, data quantity, query parameters, title attributes, and table headers corresponding to the title attributes in the query template includes:
[0074] Pre-set one-to-one corresponding query codes for the parameter names of the query parameters;
[0075] If the received query instruction carries a query code, determining and obtaining a parameter name of a corresponding query parameter in the query template according to the query code;
[0076] If the received query instruction does not carry a preset query code, then obtaining parameter names of all query parameters;
[0077] The electronic table name, data quantity, title attributes, and table header corresponding to the title attributes in the query template are read.
[0078] In this embodiment, the parameter name is determined based on the query code. This allows the system to control the data retrieved without modifying the parameter name. Instead, the system simply enters the corresponding query code, achieving convenient and dynamic control over data retrieval. If the received query instruction does not carry a query code, all query parameters are retrieved, thereby obtaining business data in the database that meets all query conditions.
[0079] In this embodiment, the method for exporting a spreadsheet file is executed on an electronic device (eg Figure 1 The server / terminal device shown in the figure can receive the query instruction via a wired connection or a wireless connection. It should be noted that the above-mentioned wireless connection method may include but is not limited to 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0080] In addition, in step S1, that is, after the step of creating the query template, the following steps are further included:
[0081] Encrypting the query template using a preset key to generate ciphertext, and storing the ciphertext in a database;
[0082] In step S2, that is, when a query instruction is received, the step of reading the electronic form name, data quantity, query parameters, title attributes, and table headers corresponding to the title attributes in the query template includes:
[0083] When receiving a query instruction carrying a key, obtaining the key carried in the query instruction, decrypting the ciphertext using the key, and obtaining the query template;
[0084] The electronic table name, data quantity, query parameters, title attributes and table headers corresponding to the title attributes in the query template are read.
[0085] In this embodiment, the present application can select a commonly used encryption method to encrypt the query template, including but not limited to any one of MD5 encryption, HMAC encryption, and base64 encryption. By encrypting the query template, the present application ensures the security of the query template, prevents other persons from arbitrarily obtaining the query template, and prevents tampering with the query template.
[0086] S3: According to the mapping relationship between the parameter name in the query parameter and the condition name, the obtained parameter name is used to replace the corresponding condition name in the structured query language to be executed, so as to complete the assembly of the structured query language to be executed.
[0087] In this embodiment, the parameter name of the obtained query parameter replaces the condition name of the query condition in the structured query language to be executed to obtain the assembled structured query language to be executed; and the parameter name can also be dynamically modified when the system is running without interfering with the execution of the database execution statement.
[0088] S4: Execute the structured query language to be executed to obtain business data from the database.
[0089] In this embodiment, the corresponding data value is obtained according to the parameter name, and all the obtained data values constitute the business data; the required data value is obtained from the database according to the structured query language to be executed that is automatically assembled by the computer, which avoids the need to rewrite a set of export functions every time a different data value is obtained, reducing development costs and improving efficiency. Specifically, for example, name: Zhang San; name is the parameter name, and Zhang San is the data value; to further explain, "name" is called "parameter name" in the query parameters of the page and "attribute name" in the database. The query parameters in this application include parameter names, and the parameter names have a one-to-one mapping relationship with the attribute names in the database. The attribute name is obtained according to the parameter name, and the corresponding data value is found in the database according to the attribute name. The parameter names in this application can be modified according to actual needs during actual operation.
[0090] Specifically, in step S4, that is, executing the structured query language to be executed, the step of obtaining business data from the database includes:
[0091] Obtaining the number of data in the query template, and determining the number of business data to be obtained from the database according to the structured query language to be executed;
[0092] comparing the amount of the business data with the number of data;
[0093] If the amount of the business data is less than or equal to the number of data, the structured query language to be executed is executed to obtain the business data from the database.
[0094] If the amount of the business data is greater than the number of data, the structured query language to be executed is executed to obtain business data from the database in multiple times, wherein the amount of business data obtained each time is less than or equal to the number of data.
[0095] In this embodiment, if the amount of business data is less than or equal to the number of data, it means that the amount of business data to be obtained from the database meets the requirements, and the structured query language to be executed can be directly executed. This application adds a quantity comparison process to ensure that the system can bear the amount of data to be obtained, effectively reducing the occurrence of system downtime. This application presets the number of data in the query template to ensure that the amount of business data obtained each time is less than or equal to the number of data. If the amount of business data to be obtained is too much, you can communicate with relevant personnel to change the query parameters and then change the query conditions to effectively control the amount of business data obtained, ensure the rapid response and operation of the system, avoid system overload, and extend the service life of the system.
[0096] In addition, in step S4, that is, executing the structured query language to be executed, the step of obtaining business data from the database includes:
[0097] Obtaining the number of data in the query template, and determining the number of business data to be obtained from the database according to the structured query language to be executed;
[0098] comparing the amount of the business data with the number of data;
[0099] If the amount of the business data is greater than the number of data, identifying the level tag pre-applied to the parameter name, wherein the level tag includes at least a first level and a second level;
[0100] Delete and back up the parameter names marked with levels other than the first level, and send the deleted parameter names to the designated person via email;
[0101] All parameter names in the structured query language to be executed are replaced with the parameter names marked with the first-level level, and the structured query language to be executed is executed to obtain business data from the database.
[0102] In this embodiment, the present application can also directly delete parameter names with levels other than the first level in the already assembled structured query language to be executed, without having to perform a replacement operation. However, performing the replacement operation helps record the log and facilitate future tracing. By deleting parameter names with lower level marks, the present application reduces the amount of business data obtained, thereby ensuring the operation and response speed of the system while obtaining the main business data.
[0103] S5: Generate and output a spreadsheet according to the obtained header, business data, spreadsheet name and data quantity.
[0104] In this embodiment, the spreadsheet of this application includes but is not limited to Excel spreadsheets; the Excel tool pre-stored in the system can be called to generate and output the spreadsheet based on the obtained table header, business data, spreadsheet name and data quantity.
[0105] This application introduces a template mode, first defines the template, sets the rules, reads the template information according to the set rules, and completes the export of the spreadsheet. In the process of parsing the template, by parsing the parameter name of the query parameter, according to the mapping relationship, the parameter name is used to replace the condition name in the database execution statement, and the assembled database execution statement is obtained, so that the database execution statement is executed and the required data value is obtained from the database, avoiding the need to rewrite a set of export functions every time different data values are obtained, reducing development costs and improving efficiency. At the same time, when the system is running, the parameter name can also be dynamically modified without interfering with the execution of the database execution statement. In addition, the system obtains the corresponding data value according to the parameter name, without the need to export all the data values in the database at one time, avoiding data redundancy, improving the response speed of the system, and reducing the pressure on the system.
[0106] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When executed, the program can include the processes in the above-described method embodiments. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0107] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0108] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a device for exporting a spreadsheet file. Figure 2Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0109] like Figure 3 As shown, the apparatus 300 for exporting a spreadsheet file in this embodiment includes: a creation module 301 , a reading module 302 , a replacement module 303 , an execution module 304 and a generation module 305 . The creation module 301 is configured to create a query template, the query template including a table header, title attributes, a structured query language to be executed, a spreadsheet name, query parameters, and the number of data, and to map the table header to the title attributes one-to-one. The structured query language to be executed includes query conditions and execution statements, the query conditions including condition names, and the query parameters including parameter names, and to map the condition names to the parameter names one-to-one. The reading module 302 is configured to, upon receiving a query instruction, read the spreadsheet name, the number of data, query parameters, title attributes, and the table header corresponding to the title attributes from the query template. The replacement module 303 is configured to, based on the mapping relationship between the parameter names in the query parameters and the condition names, replace the corresponding condition names in the structured query language to be executed with the acquired parameter names to complete the assembly of the structured query language to be executed. The execution module 304 is configured to execute the structured query language to be executed and acquire business data from a database. The generation module 305 is configured to generate and output a spreadsheet based on the acquired table header, business data, spreadsheet name, and the number of data.
[0110] In this embodiment, the present application introduces a template mode, first defining the template and setting the rules, then reading the template information according to the set rules to complete the Excel export. The use of placeholders in the database execution statement prevents SQL injection, and in the process of parsing the template, by parsing the parameter names of the query parameters, the condition names in the database execution statement are replaced with the parameter names according to the mapping relationship to obtain the assembled database execution statement, thereby executing the database execution statement and obtaining the required data values from the database. This avoids the need to rewrite a set of export functions each time a different data value is obtained, reducing development costs and improving efficiency. At the same time, the parameter names can be dynamically modified during system operation without interfering with the execution of the database execution statement. Furthermore, the system obtains the corresponding data value based on the parameter name, without having to export all the data values in the database at once, avoiding data redundancy, improving the system's response speed, and reducing system pressure.
[0111] The reading module 302 includes a setting submodule, an acquisition submodule, and a reading submodule; the setting submodule is used to pre-set a one-to-one corresponding query code for the parameter name of the query parameter; the acquisition submodule is used to determine and acquire the parameter name of the corresponding query parameter in the query template according to the query code when the received query instruction carries the query code, and acquire the parameter names of all query parameters when the received query instruction does not carry the pre-set query code; the reading submodule is used to read the spreadsheet name, data number, title attributes, and table header corresponding to the title attributes in the query template.
[0112] The execution module 304 includes a determination submodule, a comparison submodule and an execution submodule. The determination submodule is used to obtain the number of data in the query template and determine the number of business data to be obtained from the database based on the structured query language to be executed; the comparison submodule is used to compare the number of business data with the number of data; the execution submodule is used to execute the structured query language to be executed and obtain business data from the database when the number of business data is less than or equal to the number of data, and when the number of business data is greater than the number of data, execute the structured query language to be executed and obtain business data from the database in multiple times, wherein the number of business data obtained each time is less than or equal to the number of data.
[0113] In addition, the execution submodule includes an identification unit, a deletion unit and a replacement unit; the identification unit is used to identify the level marking of the parameter name in advance when the amount of the business data is greater than the number of data, wherein the level marking includes at least the first level and the second level; the deletion unit is used to delete and back up the parameter names of the levels marked other than the first level, and send the deleted parameter names to the designated person via email; the replacement unit is used to replace all parameter names in the structured query language to be executed with the parameter names marked with the first level, and execute the structured query language to be executed to obtain business data from the database.
[0114] In some optional implementations of this embodiment, the apparatus 300 further includes: a setting module and an encryption module, wherein the setting module is configured to set the query condition as a placeholder in the query template; the encryption module is configured to encrypt the query template using a preset key to generate ciphertext and store the ciphertext in a database. The reading module 302 further includes a decryption submodule, which is configured to, upon receiving a query instruction carrying a key, obtain the key carried in the query instruction, decrypt the ciphertext using the key, obtain the query template, and transmit the obtained query template to the reading submodule.
[0115] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0116] The computer device 200 includes a memory 201, a processor 202, and a network interface 203 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 200 having components 201-203, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0117] The computer device may be a desktop computer, notebook computer, PDA, cloud server, etc. The computer device may interact with the user via a keyboard, mouse, remote control, touchpad, or voice control device.
[0118] The memory 201 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 201 may be an internal storage unit of the computer device 200, such as a hard disk or memory of the computer device 200. In other embodiments, the memory 201 may also be an external storage device of the computer device 200, such as a plug-in hard disk equipped on the computer device 200, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Of course, the memory 201 may also include both the internal storage unit of the computer device 200 and its external storage device. In this embodiment, the memory 201 is generally used to store the operating system and various application software installed on the computer device 200, such as the program code of the method for exporting a spreadsheet file. In addition, the memory 201 can also be used to temporarily store various data that has been output or is about to be output.
[0119] In some embodiments, the processor 202 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 202 is generally used to control the overall operation of the computer device 200. In this embodiment, the processor 202 is used to execute program code stored in the memory 201 or process data, such as executing the program code of the method for exporting a spreadsheet file.
[0120] The network interface 203 may include a wireless network interface or a wired network interface. The network interface 203 is generally used to establish a communication connection between the computer device 200 and other electronic devices.
[0121] In this embodiment, parameter names can be dynamically modified while the system is running without interfering with the execution of database statements. Furthermore, the system retrieves the corresponding data value based on the parameter name without having to export all the data values in the database at once, thus avoiding data redundancy and improving system response speed.
[0122] The present application also provides another embodiment, namely, providing a computer-readable storage medium, which stores a program for exporting a spreadsheet file. The program for exporting a spreadsheet file can be executed by at least one processor to enable the at least one processor to perform the steps of the method for exporting a spreadsheet file as described above.
[0123] In this embodiment, parameter names can be dynamically modified while the system is running without interfering with the execution of database statements. Furthermore, the system retrieves the corresponding data value based on the parameter name without having to export all the data values in the database at once, thus avoiding data redundancy and improving system response speed.
[0124] Blockchain, as used in this article, refers to a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each block contains information about a batch of online transactions, used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0125] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0126] Obviously, the embodiments described above are only some of the embodiments of the present application, rather than all of the embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions described in the aforementioned specific embodiments, or to make equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the present application specification and the accompanying drawings, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present application.
Claims
1. A method for exporting a spreadsheet file, characterized in that: The steps include: Creating a query template, the query template including a table header, a title attribute, a structured query language to be executed, a spreadsheet name, query parameters, and the number of data, and mapping the table header to the title attribute one-to-one; the structured query language to be executed including a query condition and an execution statement, the query condition including a condition name, the query parameter including a parameter name, and mapping the condition name to the parameter name one-to-one; When a query instruction is received, the electronic form name, the number of data, the query parameters, the title attributes and the table header corresponding to the title attributes in the query template are read; According to the mapping relationship between the parameter name in the query parameter and the condition name, the obtained parameter name is used to replace the corresponding condition name in the structured query language to be executed, so as to complete the assembly of the structured query language to be executed; Executing the structured query language to be executed to obtain business data from the database; and Generate and output a spreadsheet based on the obtained header, business data, spreadsheet name and data quantity; The step of executing the structured query language to be executed and obtaining business data from the database includes: Obtaining the number of data in the query template, and determining the number of business data to be obtained from the database according to the structured query language to be executed; comparing the amount of the business data with the number of data; If the amount of the business data is greater than the number of data, identifying the level tag pre-applied to the parameter name, wherein the level tag includes at least a first level and a second level; Delete and back up the parameter names marked at levels other than the first level, and send the deleted parameter names to the designated personnel via email; All parameter names in the structured query language to be executed are replaced with the parameter names marked with the first-level level, and the structured query language to be executed is executed to obtain business data from the database.
2. The method for exporting a spreadsheet file according to claim 1, wherein: The step of reading the electronic form name, data quantity, query parameters, title attributes and table headers corresponding to the title attributes in the query template includes: Pre-set one-to-one corresponding query codes for the parameter names of the query parameters; If the received query instruction carries a query code, determining and obtaining a parameter name of a corresponding query parameter in the query template according to the query code; If the received query instruction does not carry a preset query code, then obtaining parameter names of all query parameters; The electronic table name, data quantity, title attributes, and table header corresponding to the title attributes in the query template are read.
3. The method for exporting a spreadsheet file according to claim 1, wherein: After the step of creating the query template, the method further includes: Encrypting the query template using a preset key to generate ciphertext, and storing the ciphertext in a database; The step of reading the electronic form name, data quantity, query parameters, title attributes and table headers corresponding to the title attributes in the query template when a query instruction is received includes: When receiving a query instruction carrying a key, obtaining the key carried in the query instruction, decrypting the ciphertext using the key, and obtaining the query template; The electronic table name, data quantity, query parameters, title attributes and table headers corresponding to the title attributes in the query template are read.
4. The method for exporting a spreadsheet file according to claim 1, wherein: After the step of mapping the condition names to the parameter names one by one, the method further includes: The query condition is set in the query template in the form of a placeholder.
5. The method for exporting a spreadsheet file according to any one of claims 1 to 4, characterized in that: The step of executing the structured query language to be executed and obtaining business data from the database includes: Obtaining the number of data in the query template, and determining the number of business data to be obtained from the database according to the structured query language to be executed; comparing the amount of the business data with the number of data; If the amount of the business data is less than or equal to the number of data, executing the to-be-executed structured query language to obtain the business data from the database; If the amount of the business data is greater than the number of data, the structured query language to be executed is executed to obtain business data from the database in multiple times, wherein the amount of business data obtained each time is less than or equal to the number of data.
6. A device for exporting a spreadsheet file, characterized in that: include: a creation module, configured to create a query template, the query template including a table header, a title attribute, a structured query language to be executed, a spreadsheet name, query parameters, and a data quantity, and mapping the table header to the title attribute one-to-one; the structured query language to be executed including a query condition and an execution statement, the query condition including a condition name, the query parameter including a parameter name, and mapping the condition name to the parameter name one-to-one; A reading module, configured to read the electronic form name, data quantity, query parameters, title attributes, and table headers corresponding to the title attributes in the query template when a query instruction is received; a replacement module, configured to replace the corresponding condition name in the structured query language to be executed with the acquired parameter name according to the mapping relationship between the parameter name in the query parameter and the condition name, so as to complete the assembly of the structured query language to be executed; An execution module, configured to execute the structured query language to be executed and obtain business data from a database; as well as A generating module, configured to generate and output a spreadsheet according to the obtained table header, business data, spreadsheet name and data quantity; Among them, the execution module is specifically used to obtain the number of data in the query template, and determine the number of business data to be obtained from the database based on the structured query language to be executed; compare the number of business data with the number of data; if the number of business data is greater than the number of data, identify the level marking of the parameter name in advance, wherein the level marking includes at least the first level and the second level; delete and back up the parameter names of other level markings except the first level, and send the deleted parameter names to the designated person via email; use the parameter names of the first level marking to replace all parameter names in the structured query language to be executed, and execute the structured query language to be executed to obtain business data from the database.
7. The device for exporting a spreadsheet file according to claim 6, characterized in that: The reading module includes a setting submodule, an acquisition submodule and a reading submodule; The setting submodule is used to pre-set a one-to-one corresponding query code for the parameter name of the query parameter; The acquisition submodule is configured to determine and acquire the parameter names of the corresponding query parameters in the query template according to the query code when the received query instruction carries a query code, and acquire the parameter names of all query parameters when the received query instruction does not carry a preset query code; The reading submodule is used to read the electronic form name, data quantity, title attributes, and table headers corresponding to the title attributes in the query template.
8. A computer device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the method for exporting a spreadsheet file according to any one of claims 1 to 5 are implemented.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for exporting a spreadsheet file according to any one of claims 1 to 5.