CN112036130A - Method and device for exporting Excel data and electronic equipment - Google Patents

Method and device for exporting Excel data and electronic equipment Download PDF

Info

Publication number
CN112036130A
CN112036130A CN202010902180.8A CN202010902180A CN112036130A CN 112036130 A CN112036130 A CN 112036130A CN 202010902180 A CN202010902180 A CN 202010902180A CN 112036130 A CN112036130 A CN 112036130A
Authority
CN
China
Prior art keywords
target
excel
parameter
name
data source
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010902180.8A
Other languages
Chinese (zh)
Other versions
CN112036130B (en
Inventor
王晨旭
张诗文
陈康龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur General Software Co Ltd
Original Assignee
Shandong Inspur Genersoft Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Inspur Genersoft Information Technology Co Ltd filed Critical Shandong Inspur Genersoft Information Technology Co Ltd
Priority to CN202010902180.8A priority Critical patent/CN112036130B/en
Publication of CN112036130A publication Critical patent/CN112036130A/en
Application granted granted Critical
Publication of CN112036130B publication Critical patent/CN112036130B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides an export method and device of Excel data and electronic equipment, wherein the method comprises the following steps: determining a preset original Excel data export method; inputting at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter into an original Excel data export method according to a pre-constructed dynamic link library and the original Excel data export method, wherein the dynamic link library is a target data source for acquiring target Excel data; generating a target Excel data export method according to at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter; determining a target data source of the target Excel data according to the parameters of the dynamic link library; and according to the target Excel data export method, exporting the target Excel data from the target data source. According to the scheme, the export of Excel data can be facilitated.

Description

Method and device for exporting Excel data and electronic equipment
Technical Field
The invention relates to the technical field of computers, in particular to an Excel data exporting method and device and electronic equipment.
Background
When batch data is operated in a software system, Excel data operation is often involved, Excel generally needs to be exported after the system queries a required data generation table, but the exported data are different according to different query results, and how to rapidly export different excels becomes a great problem to be solved urgently.
Currently, different Excel data export methods are generally written aiming at different query results, so that the export of Excel data is inconvenient.
Disclosure of Invention
The embodiment of the invention provides an export method and device of Excel data and electronic equipment, which can facilitate the export of the Excel data.
In a first aspect, an embodiment of the present invention provides a method for exporting Excel data, where the method includes:
determining a preset original Excel data export method;
inputting at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter into the original Excel data export method according to a pre-constructed dynamic link library and the original Excel data export method, wherein the dynamic link library is a target data source for acquiring target Excel data;
generating a target Excel data export method according to the at least one target Excel column header parameter, the target Excel name parameter and the dynamic link library parameter;
determining the target data source of the target Excel data according to the dynamic link library parameters;
and exporting the target Excel data from the target data source according to the target Excel data export method.
Preferably, the first and second electrodes are formed of a metal,
the at least one target Excel column header parameter comprises: the method comprises the following steps of obtaining at least one target Excel column head name parameter, at least one database field name parameter corresponding to the target Excel column head name and at least one format item parameter corresponding to the target Excel column head;
the dynamically linked library parameters include: one or more of a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source, and a target data source calling method parameter.
Preferably, the first and second electrodes are formed of a metal,
the determining the target data source of the target Excel data according to the dynamic link library parameters comprises the following steps:
analyzing a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source and a target data source calling method parameter which are included in the parameters of the dynamic link library by adopting a reflection mechanism;
creating a class object according to the incoming assembly information;
creating an instance of a method from the incoming release information;
analyzing the parameters of the target data source calling method to call a target data source obtaining method so as to obtain the target data source, wherein the target data source comprises all data information of the target Excel.
Preferably, the first and second electrodes are formed of a metal,
the exporting of the target Excel data from the target data source according to the target Excel data exporting method comprises the following steps:
analyzing the target Excel name parameter to generate the name of the first line of the target Excel data;
analyzing the at least one target Excel column header parameter and determining at least one column header information;
circularly traversing the at least one column header information;
circularly traversing the target data source;
analyzing database field name parameters corresponding to the at least one target Excel column header name, and determining the database field name corresponding to the at least one target Excel column header name;
determining a database value corresponding to each Excel cell from the target data source according to the database field name corresponding to the at least one target Excel column header name;
determining format item information corresponding to the at least one target Excel column header according to the format item parameters corresponding to the at least one target Excel column header;
setting the format of the target Excel according to the format item information corresponding to the at least one target Excel column header;
and exporting the target Excel data from the target data source.
In a second aspect, an embodiment of the present invention provides an apparatus for exporting Excel data, including:
the original method determination module is used for determining a preset original Excel data export method;
the parameter input module is used for inputting at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter into the original Excel data export method according to a pre-constructed dynamic link library and the original Excel data export method determined by the original method determination module, wherein the dynamic link library is a target data source for acquiring target Excel data;
the target method determining module is used for generating a target Excel data export method according to at least one target Excel column header parameter, the target Excel name parameter and the dynamic link library parameter which are input by the parameter input module;
the data source determining module is used for determining the target data source of the target Excel data according to the dynamic link library parameters input by the parameter input module;
and the data export module is used for exporting the target Excel data from the target data source determined by the data source determination module according to the target Excel data export method determined by the target method determination module.
Preferably, the first and second electrodes are formed of a metal,
further comprising: setting a module;
the setting module is configured to set the at least one target Excel column header parameter, and includes: the method comprises the following steps of obtaining at least one target Excel column head name parameter, at least one database field name parameter corresponding to the target Excel column head name and at least one format item parameter corresponding to the target Excel column head; setting the dynamically linked library parameters comprises: one or more of a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source, and a target data source calling method parameter.
Preferably, the first and second electrodes are formed of a metal,
the data source determination module is configured to perform:
analyzing a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source and a target data source calling method parameter which are included in the parameters of the dynamic link library by adopting a reflection mechanism;
creating a class object according to the incoming assembly information;
creating an instance of a method from the incoming release information;
analyzing the parameters of the target data source calling method to call a target data source obtaining method so as to obtain the target data source, wherein the target data source comprises all data information of the target Excel.
Preferably, the first and second electrodes are formed of a metal,
the data export module is configured to perform:
analyzing the target Excel name parameter to generate the name of the first line of the target Excel data;
analyzing the at least one target Excel column header parameter and determining at least one column header information;
circularly traversing the at least one column header information;
circularly traversing the target data source;
analyzing database field name parameters corresponding to the at least one target Excel column header name, and determining the database field name corresponding to the at least one target Excel column header name;
determining a database value corresponding to each Excel cell from the target data source according to the database field name corresponding to the at least one target Excel column header name;
determining format item information corresponding to the at least one target Excel column header according to the format item parameters corresponding to the at least one target Excel column header;
setting the format of the target Excel according to the format item information corresponding to the at least one target Excel column header;
and exporting the target Excel data from the target data source.
In a third aspect, an embodiment of the present invention provides an electronic device, including: at least one memory and at least one processor;
the at least one memory to store a machine readable program;
the at least one processor is configured to invoke the machine-readable program to perform the method of any of the first aspects.
In a fourth aspect, the present invention provides a computer-readable medium, where computer instructions are stored on the computer-readable medium, and when executed by a processor, cause the processor to perform the method of any one of the first aspect.
The embodiment of the invention provides an export method and device of Excel data and electronic equipment, wherein the existing export method of Excel data needs to write an export method for each query result independently, which increases the workload of developers and causes the export of Excel data to be inconvenient, so that in order to facilitate the export of Excel data, a column header parameter of target Excel and a dynamic link library parameter of a target data source can be input into an original Excel data export method, so that a universal export method of Excel data can be generated. Based on the method, at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter can be input into the original Excel data export method according to a dynamic link library and an original Excel data export method which are constructed in advance, the target Excel data export method is generated based on the at least one target Excel column header parameter, the target Excel name parameter and the dynamic link library parameter, a target data source of the target Excel data is determined based on the dynamic link library parameter, and then the target Excel data is exported from the target data source based on the determined target Excel data export method. By the method, different Excel data export methods do not need to be written for each query result, and export of Excel data can be facilitated.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flowchart of a method for exporting Excel data according to an embodiment of the present invention;
FIG. 2 is a flowchart of another Excel data export method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an apparatus for exporting Excel data according to an embodiment of the present invention;
fig. 4 is a schematic diagram of another apparatus for exporting Excel data according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer and more complete, the technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention, and based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without creative efforts belong to the scope of the present invention.
As shown in fig. 1, an embodiment of the present invention provides a method for exporting Excel data, which may include the following steps:
step 101: determining a preset original Excel data export method;
step 102: inputting at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter into an original Excel data export method according to a pre-constructed dynamic link library and the original Excel data export method, wherein the dynamic link library is a target data source for acquiring target Excel data;
step 103: generating a target Excel data export method according to at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter;
step 104: determining a target data source of the target Excel data according to the parameters of the dynamic link library;
step 105: and according to the target Excel data export method, exporting the target Excel data from the target data source.
In the embodiment of the invention, the existing export method of Excel data needs to write an export method for each query result independently, which increases the workload of developers and causes inconvenience in export of Excel data, so that in order to facilitate export of Excel data, a column header parameter of a target Excel and a dynamic link library parameter of a target data source can be input into an original Excel data export method, so as to generate a universal export method of Excel data. Based on the method, at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter can be input into the original Excel data export method according to a dynamic link library and an original Excel data export method which are constructed in advance, the target Excel data export method is generated based on the at least one target Excel column header parameter, the target Excel name parameter and the dynamic link library parameter, a target data source of the target Excel data is determined based on the dynamic link library parameter, and then the target Excel data is exported from the target data source based on the determined target Excel data export method. By the method, different Excel data export methods do not need to be written for each query result, and export of Excel data can be facilitated.
In order to obtain target Excel data from a target data source, in an embodiment of the present invention, at least one target Excel column header parameter in the foregoing embodiment includes: the method comprises the following steps of obtaining at least one target Excel column head name parameter, at least one database field name parameter corresponding to the target Excel column head name and at least one format item parameter corresponding to the target Excel column head;
dynamically linked library parameters, including: the method comprises one or more of a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source and a target data source calling method parameter.
In the embodiment of the present invention, an Excel table data needs to obtain Excel data from a target data source based on an Excel column header name and a format item corresponding to an Excel column header, and therefore, at least one target Excel column header parameter can be set to include: the method comprises the following steps that at least one target Excel column head name parameter, at least one database field name parameter corresponding to the target Excel column head name and at least one format item parameter corresponding to the target Excel column head are set, and meanwhile, the setting of the dynamic link library parameters comprises the following steps: one or more of a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source and a target data source calling method parameter are adopted, so that Excel data can be acquired from the target data source based on the at least one target Excel column header parameter.
In order to determine a target data source, in an embodiment of the present invention, in the above embodiment, the step 104 determines the target data source of the target Excel data according to the dynamic link library parameter, which may be specifically implemented by the following manner:
analyzing a file name parameter of a dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of a target data source and a target data source calling method parameter which are included in the parameters of the dynamic link library by adopting a reflection mechanism;
creating a class object according to the incoming assembly information;
creating an instance of a method from the incoming release information;
and analyzing the parameters of the target data source calling method to call the target data source obtaining method so as to obtain the target data source, wherein the target data source comprises all data information of the target Excel.
In the embodiment of the invention, the dynamic link library is used for acquiring all data information of the target Excel data, so that a reflection mechanism can be adopted for analyzing the file name parameter of the dynamic link library, the name space parameter of the dynamic link library, the class name parameter of the dynamic link library, the method name acquisition parameter of the target data source and the target data source calling method parameter which are included in the parameters of the dynamic link library, and then the target Excel data is acquired based on the parameters, so that a class object can be created according to the incoming program set information, an example of a method is created according to the incoming release information, and the target data source calling method parameter is analyzed to call the target data source acquisition method so as to acquire the target data source.
In order to derive target Excel data from a target data source, in an embodiment of the present invention, in step 105 in the above embodiment, the deriving of the target Excel data from the target data source according to the target Excel data derivation method may be specifically implemented by the following manner:
analyzing the name parameter of the target Excel to generate the name of the first line of the target Excel data;
analyzing at least one target Excel column header parameter and determining at least one column header information;
circularly traversing at least one column header information;
circularly traversing the target data source;
analyzing database field name parameters corresponding to at least one target Excel column head name, and determining the database field name corresponding to at least one target Excel column head name;
determining a database value corresponding to each Excel cell from a target data source according to a database field name corresponding to at least one target Excel column header name;
determining format item information corresponding to at least one target Excel column header according to the format item parameters corresponding to the at least one target Excel column header;
setting the format of the target Excel according to the format item information corresponding to at least one target Excel column header;
and deriving target Excel data from the target data source.
In the embodiment of the invention, when the Excel data is exported, the input column header information can be circularly traversed based on the target Excel name parameter as the name of the first line of the Excel data, the target data source is circularly traversed, the database value corresponding to each cell is determined according to the database field corresponding to the column header, and the target Excel data is exported by acquiring the target Excel data from the target data source. Meanwhile, the format of the target Excel can be set according to the format item information corresponding to at least one column header of the target Excel, for example, the style of the table body of the target Excel is set according to the information of the column header, such as the left, the right and the like.
In an embodiment of the present invention, the logic displayed on the conventional query analysis list interface is basically divided into three steps: determining the name of a column header information item displayed on a list interface and the name of a data field corresponding to the information item according to the specific service logic of query analysis; inquiring a database according to the service logic writing codes to obtain a data source; binding the data source to the list; however, information items and data displayed on the list interface are often different, exported Excel is also different, and if the export method is rewritten according to the query result every time, the export method is low in efficiency and large in workload. The method has the characteristics of universality, simplicity, convenience and individuation, can be suitable for most queries, does not need to independently write and derive a method for each query, can greatly reduce the development workload and shorten the development period; the method is convenient and fast to call, and only the column header and the dynamic link library information for query are required to be input to generate the Excel file; aiming at the personalized requirements, a plurality of personalized styles are built in the method, and the personalized styles such as fonts, word sizes, colors and the like can be set aiming at the cells with the requirements.
As shown in fig. 2, the following describes in detail a technical solution and an advantage of the method for exporting Excel data according to the embodiment of the present invention, and includes the following steps:
step 201: and determining a preset original Excel data export method.
Step 202: inputting at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter into the original Excel data export method according to a pre-constructed dynamic link library and an original Excel data export method, wherein the dynamic link library is a target data source for acquiring target Excel data.
Step 203: and generating a target Excel data export method according to at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter.
By way of example, this may be achieved by:
Figure BDA0002660140430000101
Figure BDA0002660140430000111
step 204: and analyzing the file name parameter of the dynamic link library, the name space parameter of the dynamic link library, the class name parameter of the dynamic link library, the method name acquisition parameter of the target data source and the calling method parameter of the target data source, which are included in the parameters of the dynamic link library, by adopting a reflection mechanism.
Step 205: a class object is created from the incoming assembly information.
Step 206: an instance of a method is created from the incoming release information.
Step 207: and analyzing the parameters of the target data source calling method to call the target data source obtaining method so as to obtain the target data source, wherein the target data source comprises all data information of the target Excel.
By way of example, this may be achieved by:
Figure BDA0002660140430000121
Figure BDA0002660140430000131
Figure BDA0002660140430000141
Figure BDA0002660140430000151
step 208: and analyzing the target Excel name parameter to generate the name of the first line of the target Excel data.
Step 209: and analyzing at least one target Excel column header parameter and determining at least one column header information.
Step 210: and circularly traversing at least one column header information.
Step 211: and circularly traversing the target data source.
Step 212: analyzing the database field name parameter corresponding to the at least one target Excel column head name, and determining the database field name corresponding to the at least one target Excel column head name.
Step 213: and determining a database value corresponding to each Excel cell from a target data source according to the database field name corresponding to the at least one target Excel column header name.
Step 214: and determining format item information corresponding to at least one target Excel column header according to the format item parameters corresponding to the at least one target Excel column header.
Step 215: and setting the format of the target Excel according to the format item information corresponding to at least one target Excel column header.
Step 216: and deriving target Excel data from the target data source.
By way of example, this may be achieved by:
Figure BDA0002660140430000152
Figure BDA0002660140430000161
Figure BDA0002660140430000171
Figure BDA0002660140430000181
as shown in fig. 3, an embodiment of the present invention provides an apparatus for exporting Excel data, including:
an original method determining module 301, configured to determine a preset original Excel data export method;
the parameter input module 302 is configured to input at least one target Excel column header parameter, a target Excel name parameter, and a dynamic link library parameter into an original Excel data export method according to a pre-constructed dynamic link library and the original Excel data export method determined by the original method determination module 301, where the dynamic link library is a target data source used for acquiring target Excel data;
the target method determining module 303 is used for generating a target Excel data export method according to at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter which are input by the parameter input module 302;
the data source determining module 304 is used for determining a target data source of the target Excel data according to the dynamic link library parameters input by the parameter input module 302;
the data export module 305 is configured to export the target Excel data from the target data source determined by the data source determination module 304 according to the target Excel data export method determined by the target method determination module 303.
In the embodiment of the invention, the existing export method of Excel data needs to write an export method separately for each query result, which increases the workload of developers and causes inconvenience in export of Excel data, so that in order to facilitate export of Excel data, a column header parameter of a target Excel and a dynamic link library parameter of a target data source can be input into an original Excel data export method, so as to generate a general export method of Excel data. Based on the method, at least one target Excel column head parameter, a target Excel name parameter and a dynamic link library parameter can be input into the original Excel data export method through a parameter input module according to a pre-constructed dynamic link library and an original Excel data export method, a target Excel data export method is generated through a target method determination module based on at least one target Excel column head parameter, target Excel name parameter and dynamic link library parameter, a target data source of target Excel data is determined based on the dynamic link library parameter, and then the target Excel data is exported from the target data source through a data export module based on the determined target Excel data export method. By the method, different Excel data export methods do not need to be written for each query result, and export of Excel data can be facilitated.
As shown in fig. 4, the apparatus for exporting Excel data according to fig. 1 further includes, in an embodiment of the present invention: a setup module 306;
the setting module 306 is configured to set at least one target Excel column header parameter, including: the method comprises the following steps of obtaining at least one target Excel column head name parameter, at least one database field name parameter corresponding to the target Excel column head name and at least one format item parameter corresponding to the target Excel column head; setting the parameters of the dynamic link library comprises the following steps: the method comprises one or more of a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source and a target data source calling method parameter.
In an embodiment of the present invention, the data source determining module 304 is configured to perform:
analyzing a file name parameter of a dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of a target data source and a target data source calling method parameter which are included in the parameters of the dynamic link library by adopting a reflection mechanism;
creating a class object according to the incoming assembly information;
creating an instance of a method from the incoming release information;
and analyzing the parameters of the target data source calling method to call the target data source obtaining method so as to obtain the target data source, wherein the target data source comprises all data information of the target Excel.
In an embodiment of the present invention, the data export module 305 is configured to perform:
analyzing the name parameter of the target Excel to generate the name of the first line of the target Excel data;
analyzing at least one target Excel column header parameter and determining at least one column header information;
circularly traversing at least one column header information;
circularly traversing the target data source;
analyzing database field name parameters corresponding to at least one target Excel column head name, and determining the database field name corresponding to at least one target Excel column head name;
determining a database value corresponding to each Excel cell from a target data source according to a database field name corresponding to at least one target Excel column header name;
determining format item information corresponding to at least one target Excel column header according to the format item parameters corresponding to the at least one target Excel column header;
setting the format of the target Excel according to the format item information corresponding to at least one target Excel column header;
and deriving target Excel data from the target data source.
It is understood that the schematic structure in the embodiment of the present invention does not constitute a specific limitation on the device for exporting Excel data. In other embodiments of the invention, the means for deriving Excel data may comprise more or fewer components than those shown, or some components may be combined, some components may be split, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Because the information interaction, execution process, and other contents between the units in the device are based on the same concept as the method embodiment of the present invention, specific contents may refer to the description in the method embodiment of the present invention, and are not described herein again.
The embodiment of the invention also provides a device for exporting Excel data, which comprises the following components: at least one memory and at least one processor;
at least one memory for storing a machine readable program;
and the at least one processor is used for calling the machine readable program and executing the Excel data export method in any embodiment of the invention.
The embodiment of the invention also provides a computer readable medium, wherein computer instructions are stored on the computer readable medium, and when the computer instructions are executed by a processor, the processor is enabled to execute the method for exporting the Excel data in any embodiment of the invention.
Specifically, a system or an apparatus equipped with a storage medium on which software program codes that realize the functions of any of the above-described embodiments are stored may be provided, and a computer (or a CPU or MPU) of the system or the apparatus is caused to read out and execute the program codes stored in the storage medium.
In this case, the program code itself read from the storage medium can realize the functions of any of the above-described embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
Examples of the storage medium for supplying the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (e.g., CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD + RW), a magnetic tape, a nonvolatile memory card, and a ROM. Alternatively, the program code may be downloaded from a server computer via a communications network.
Further, it should be clear that the functions of any one of the above-described embodiments may be implemented not only by executing the program code read out by the computer, but also by causing an operating system or the like operating on the computer to perform a part or all of the actual operations based on instructions of the program code.
Further, it is to be understood that the program code read out from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion unit connected to the computer, and then causes a CPU or the like mounted on the expansion board or the expansion unit to perform part or all of the actual operations based on instructions of the program code, thereby realizing the functions of any of the above-described embodiments.
The embodiments of the invention have at least the following beneficial effects:
1. in the embodiment of the invention, the existing export method of Excel data needs to write an export method for each query result independently, which increases the workload of developers and causes inconvenience in export of Excel data, so that in order to facilitate export of Excel data, a column header parameter of a target Excel and a dynamic link library parameter of a target data source can be input into an original Excel data export method, so as to generate a universal export method of Excel data. Based on the method, at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter can be input into the original Excel data export method according to a dynamic link library and an original Excel data export method which are constructed in advance, the target Excel data export method is generated based on the at least one target Excel column header parameter, the target Excel name parameter and the dynamic link library parameter, a target data source of the target Excel data is determined based on the dynamic link library parameter, and then the target Excel data is exported from the target data source based on the determined target Excel data export method. By the method, different Excel data export methods do not need to be written for each query result, and export of Excel data can be facilitated;
2. in an embodiment of the invention, the dynamic link library is used for acquiring all data information of the target Excel data, so that a reflection mechanism can be adopted to analyze a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of a target data source and a target data source calling method parameter which are included in parameters of the dynamic link library, and then the target Excel data is acquired based on the parameters, so that a class object can be created according to the incoming program set information, an example of a method is created according to the incoming release information, and a target data source calling method is invoked by analyzing the target data source calling method parameter to acquire the target data source;
3. in an embodiment of the invention, the dynamic link library is used for acquiring all data information of the target Excel data, so that a reflection mechanism can be adopted to analyze a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of a target data source and a target data source calling method parameter which are included in parameters of the dynamic link library, and then the target Excel data is acquired based on the parameters, so that a class object can be created according to the incoming program set information, an example of a method is created according to the incoming release information, and a target data source calling method is invoked by analyzing the target data source calling method parameter to acquire the target data source;
4. in an embodiment of the invention, when the Excel data is exported, the input column header information can be circularly traversed based on the target Excel name parameter as the name of the first line of the Excel data, the target data source is circularly traversed, the database value corresponding to each cell is determined according to the database field corresponding to the column header, and the target Excel data is exported by acquiring the target Excel data from the target data source. Meanwhile, the format of the target Excel can be set according to the format item information corresponding to at least one column header of the target Excel, for example, the style of the table body of the target Excel is set according to the information of the column header, such as the left, the right and the like.
It should be noted that not all steps and modules in the above flows and system structure diagrams are necessary, and some steps or modules may be omitted according to actual needs. The execution order of the steps is not fixed and can be adjusted as required. The system structure described in the above embodiments may be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by a plurality of physical entities, or some components in a plurality of independent devices may be implemented together.
In the above embodiments, the hardware unit may be implemented mechanically or electrically. For example, a hardware element may comprise permanently dedicated circuitry or logic (such as a dedicated processor, FPGA or ASIC) to perform the corresponding operations. The hardware elements may also comprise programmable logic or circuitry, such as a general purpose processor or other programmable processor, that may be temporarily configured by software to perform the corresponding operations. The specific implementation (mechanical, or dedicated permanent, or temporarily set) may be determined based on cost and time considerations.
While the invention has been shown and described in detail in the drawings and in the preferred embodiments, it is not intended to limit the invention to the embodiments disclosed, and it will be apparent to those skilled in the art that various combinations of the code auditing means in the various embodiments described above may be used to obtain further embodiments of the invention, which are also within the scope of the invention.

Claims (10)

  1. The method for exporting Excel data is characterized by comprising the following steps:
    determining a preset original Excel data export method;
    inputting at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter into the original Excel data export method according to a pre-constructed dynamic link library and the original Excel data export method, wherein the dynamic link library is a target data source for acquiring target Excel data;
    generating a target Excel data export method according to the at least one target Excel column header parameter, the target Excel name parameter and the dynamic link library parameter;
    determining the target data source of the target Excel data according to the dynamic link library parameters;
    and exporting the target Excel data from the target data source according to the target Excel data export method.
  2. 2. The method of claim 1,
    the at least one target Excel column header parameter comprises: the method comprises the following steps of obtaining at least one target Excel column head name parameter, at least one database field name parameter corresponding to the target Excel column head name and at least one format item parameter corresponding to the target Excel column head;
    the dynamically linked library parameters include: one or more of a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source, and a target data source calling method parameter.
  3. 3. The method of claim 2,
    the determining the target data source of the target Excel data according to the dynamic link library parameters comprises the following steps:
    analyzing a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source and a target data source calling method parameter which are included in the parameters of the dynamic link library by adopting a reflection mechanism;
    creating a class object according to the incoming assembly information;
    creating an instance of a method from the incoming release information;
    analyzing the parameters of the target data source calling method to call a target data source obtaining method so as to obtain the target data source, wherein the target data source comprises all data information of the target Excel.
  4. 4. The method of claim 2,
    the exporting of the target Excel data from the target data source according to the target Excel data exporting method comprises the following steps:
    analyzing the target Excel name parameter to generate the name of the first line of the target Excel data;
    analyzing the at least one target Excel column header parameter and determining at least one column header information;
    circularly traversing the at least one column header information;
    circularly traversing the target data source;
    analyzing database field name parameters corresponding to the at least one target Excel column header name, and determining the database field name corresponding to the at least one target Excel column header name;
    determining a database value corresponding to each Excel cell from the target data source according to the database field name corresponding to the at least one target Excel column header name;
    determining format item information corresponding to the at least one target Excel column header according to the format item parameters corresponding to the at least one target Excel column header;
    setting the format of the target Excel according to the format item information corresponding to the at least one target Excel column header;
    and exporting the target Excel data from the target data source.
  5. An apparatus for exporting Excel data, comprising:
    the original method determination module is used for determining a preset original Excel data export method;
    the parameter input module is used for inputting at least one target Excel column header parameter, a target Excel name parameter and a dynamic link library parameter into the original Excel data export method according to a pre-constructed dynamic link library and the original Excel data export method determined by the original method determination module, wherein the dynamic link library is a target data source for acquiring target Excel data;
    the target method determining module is used for generating a target Excel data export method according to at least one target Excel column header parameter, the target Excel name parameter and the dynamic link library parameter which are input by the parameter input module;
    the data source determining module is used for determining the target data source of the target Excel data according to the dynamic link library parameters input by the parameter input module;
    and the data export module is used for exporting the target Excel data from the target data source determined by the data source determination module according to the target Excel data export method determined by the target method determination module.
  6. 6. The apparatus of claim 5,
    further comprising: setting a module;
    the setting module is configured to set the at least one target Excel column header parameter, and includes: the method comprises the following steps of obtaining at least one target Excel column head name parameter, at least one database field name parameter corresponding to the target Excel column head name and at least one format item parameter corresponding to the target Excel column head; setting the dynamically linked library parameters comprises: one or more of a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source, and a target data source calling method parameter.
  7. 7. The apparatus of claim 6,
    the data source determination module is configured to perform:
    analyzing a file name parameter of the dynamic link library, a name space parameter of the dynamic link library, a class name parameter of the dynamic link library, a method name acquisition parameter of the target data source and a target data source calling method parameter which are included in the parameters of the dynamic link library by adopting a reflection mechanism;
    creating a class object according to the incoming assembly information;
    creating an instance of a method from the incoming release information;
    analyzing the parameters of the target data source calling method to call a target data source obtaining method so as to obtain the target data source, wherein the target data source comprises all data information of the target Excel.
  8. 8. The apparatus of claim 6,
    the data export module is configured to perform:
    analyzing the target Excel name parameter to generate the name of the first line of the target Excel data;
    analyzing the at least one target Excel column header parameter and determining at least one column header information;
    circularly traversing the at least one column header information;
    circularly traversing the target data source;
    analyzing database field name parameters corresponding to the at least one target Excel column header name, and determining the database field name corresponding to the at least one target Excel column header name;
    determining a database value corresponding to each Excel cell from the target data source according to the database field name corresponding to the at least one target Excel column header name;
    determining format item information corresponding to the at least one target Excel column header according to the format item parameters corresponding to the at least one target Excel column header;
    setting the format of the target Excel according to the format item information corresponding to the at least one target Excel column header;
    and exporting the target Excel data from the target data source.
  9. 9. An electronic device, comprising: at least one memory and at least one processor;
    the at least one memory to store a machine readable program;
    the at least one processor, configured to invoke the machine readable program to perform the method of any of claims 1 to 4.
  10. 10. Computer readable medium, characterized in that it has stored thereon computer instructions which, when executed by a processor, cause the processor to carry out the method of any one of claims 1 to 4.
CN202010902180.8A 2020-09-01 2020-09-01 Excel data export method and device and electronic equipment Active CN112036130B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010902180.8A CN112036130B (en) 2020-09-01 2020-09-01 Excel data export method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010902180.8A CN112036130B (en) 2020-09-01 2020-09-01 Excel data export method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN112036130A true CN112036130A (en) 2020-12-04
CN112036130B CN112036130B (en) 2024-04-30

Family

ID=73586882

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010902180.8A Active CN112036130B (en) 2020-09-01 2020-09-01 Excel data export method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN112036130B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2006096939A1 (en) * 2005-03-18 2006-09-21 Kwok Kay Wong Remote access of heterogeneous data
US20170316447A1 (en) * 2013-03-14 2017-11-02 Oracle America, Inc. Method and System for Supporting Intelligent Export and Integration of Analytic System Data
CN110688827A (en) * 2019-08-08 2020-01-14 平安科技(深圳)有限公司 Data processing method and device, electronic equipment and storage medium
WO2020015150A1 (en) * 2018-07-18 2020-01-23 平安科技(深圳)有限公司 Method and device for dynamically exporting data table, computer apparatus, and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2006096939A1 (en) * 2005-03-18 2006-09-21 Kwok Kay Wong Remote access of heterogeneous data
US20170316447A1 (en) * 2013-03-14 2017-11-02 Oracle America, Inc. Method and System for Supporting Intelligent Export and Integration of Analytic System Data
WO2020015150A1 (en) * 2018-07-18 2020-01-23 平安科技(深圳)有限公司 Method and device for dynamically exporting data table, computer apparatus, and storage medium
CN110688827A (en) * 2019-08-08 2020-01-14 平安科技(深圳)有限公司 Data processing method and device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王旭辉;: "Excel数据导入数据库的设计实现", 现代电子技术, no. 12 *

Also Published As

Publication number Publication date
CN112036130B (en) 2024-04-30

Similar Documents

Publication Publication Date Title
CN106354492B (en) Automatic code generation method and system for quickly adjusting transaction flow docking
CN110955416A (en) Interface document generation method, device, equipment and computer storage medium
CN109558525B (en) Test data set generation method, device, equipment and storage medium
CN111209344A (en) Data synchronization method and device
CN112765023B (en) Test case generation method and device
CN111367976A (en) Method and device for exporting EXCEL file data based on JAVA reflection mechanism
CN108241720B (en) Data processing method, device and computer readable storage medium
CN110990274A (en) Data processing method, device and system for generating test case
CN116028047A (en) Page rapid generation method based on custom annotation
CN114691161A (en) Key-Value-based software system configuration method and device and electronic equipment
CN112036130A (en) Method and device for exporting Excel data and electronic equipment
CN111580794A (en) Method and device for creating business document in business management system
EP3425510B1 (en) Automated testing method for application program user interface, electronic device, system, and storage medium
CN105426676A (en) Drilling data processing method and system
CN111556039B (en) Web data export method and device for general microservice
CN111767703B (en) Form data acquisition method, device and system
CN111580791A (en) Method and device for generating window
CN114895880A (en) Code generation method and device and computer readable medium
CN113742529A (en) Multi-table front-end processing method and device
CN114490519A (en) GIM file analysis method, device, equipment and storage medium
CN109509467B (en) Code generation method and device
CN113094086A (en) Component integration method and device, computer-readable storage medium and electronic equipment
CN111562907A (en) Conversion method and system of user-defined interface data
CN111078337A (en) Pattern adjusting method, system and computer readable storage medium
CN116303627B (en) Query method and device for semiconductor test data, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20240328

Address after: No. 1036, Shandong high tech Zone wave road, Ji'nan, Shandong

Applicant after: Inspur Genersoft Co.,Ltd.

Country or region after: China

Address before: 250100 No. 2877 Kehang Road, Sun Village Town, Jinan High-tech District, Shandong Province

Applicant before: SHANDONG INSPUR GENESOFT INFORMATION TECHNOLOGY Co.,Ltd.

Country or region before: China

GR01 Patent grant
GR01 Patent grant