CN113138959A - Method for exporting data in database into Excel file - Google Patents
Method for exporting data in database into Excel file Download PDFInfo
- Publication number
- CN113138959A CN113138959A CN202010063540.XA CN202010063540A CN113138959A CN 113138959 A CN113138959 A CN 113138959A CN 202010063540 A CN202010063540 A CN 202010063540A CN 113138959 A CN113138959 A CN 113138959A
- Authority
- CN
- China
- Prior art keywords
- data
- file
- excel
- database
- exporting
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 20
- 238000006243 chemical reaction Methods 0.000 claims abstract description 6
- 230000007547 defect Effects 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000009795 derivation Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/11—File system administration, e.g. details of archiving or snapshots
- G06F16/116—Details of conversion of file system types or formats
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/172—Caching, prefetching or hoarding of files
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a method for exporting data in a database into an Excel file, which comprises the following steps: firstly, acquiring a data identifier to be exported in advance; exporting corresponding data in the database into a text file according to the data identification, and storing the text file into a cache; receiving and exporting an Excel instruction, wherein the instruction carries one or more data identifications; deleting other text files except the text file corresponding to the data identifier carried in the instruction from the cache; reading the residual text files in the cache according to the data volume set each time, performing data format conversion on the file files read each time, and writing the generated Excel file into a storage medium; and step five, repairing the Excel file to generate a file for the Excel program to read and open. The invention can reduce the waiting time of the user.
Description
Technical Field
The invention belongs to the technical field of data processing, and particularly relates to a method for exporting data in a database into an Excel file.
Background
In data processing, it is often necessary to export a batch of data into Excel. The traditional method for exporting data into an Excel file has the problems of large memory occupation and high error probability.
In order to realize exporting a large amount of low memory into an Excel file, in the prior art, a chinese patent with a patent application number CN200810057915.0 discloses an apparatus and a method for exporting data in a database into an Excel file, but the prior art has the following defects: by adopting the method of generating the text file firstly and then converting the Excel file, a user needs to wait for more time to finish data export.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a method for exporting data in a database into an Excel file, which can reduce the waiting time of a user, in view of the above-mentioned deficiencies in the prior art.
In order to solve the technical problems, the invention adopts the technical scheme that: a method for exporting data in a database into an Excel file comprises the following steps:
firstly, acquiring a data identifier to be exported in advance;
exporting corresponding data in the database into a text file according to the data identification, and storing the text file into a cache;
receiving and exporting an Excel instruction, wherein the instruction carries one or more data identifications; deleting other text files except the text file corresponding to the data identifier carried in the instruction from the cache;
reading the residual text files in the cache according to the data volume set each time, performing data format conversion on the file files read each time, and writing the generated Excel file into a storage medium;
and step five, repairing the Excel file to generate a file for the Excel program to read and open.
In the above method for exporting data in a database into an Excel file, in the first step, the pre-obtaining the identifier of the data to be exported includes: and acquiring the selection information of the front-end user on the data, and acquiring the data identifier corresponding to the selection information.
In the above method for exporting data in a database into an Excel file, in the second step, exporting corresponding data in the database into a text file according to the data identifier includes: and inquiring corresponding data in the database according to the data identification, converting the inquired data into a text file, adding the data identification to the converted text file, and storing the text file into a cache.
In the fourth step, when the remaining text files in the cache are read according to the set data amount each time, the read text files are deleted from the cache after the reading is completed each time.
Compared with the prior art, the invention has the following advantages: according to the method and the device, the data identifier to be exported is obtained in advance, so that the data can be exported into a text file in advance, and the waiting time of a user can be reduced. Deleting other text files except the text file corresponding to the data identifier carried in the instruction from the cache; derivation of unnecessary data can be avoided.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
FIG. 1 is a flow chart of the method of the present invention.
Detailed Description
As shown in fig. 1, a method for exporting data in a database into an Excel file includes:
firstly, acquiring a data identifier to be exported in advance;
when the data identification to be exported is obtained in advance, the selection information of the front-end user on the data is obtained, and the data identification corresponding to the selection information is obtained. In practice, it appears that when the user clicks on the data to be exported on the network interface, the server instantly acquires the corresponding data identifier. In the prior art, after the user finishes checking all the data to be exported, the server starts to acquire the corresponding data identifier when sending an export Excel instruction. When the user selects one data to be exported, the server immediately acquires the corresponding data identifier for subsequent operation, so that the waiting time of the user can be reduced.
Exporting corresponding data in the database into a text file according to the data identification, and storing the text file into a cache;
when exporting the corresponding data in the database into a text file according to the data identification, firstly, inquiring the corresponding data in the database according to the data identification, converting the inquired data into a text file, adding the data identification to the converted text file, and then storing the text file into a cache. In practice, a data identifier may query many pieces of data, and accordingly, a plurality of text files may be converted, and the text files are packaged into an overall text file, the data identifier is added, and the overall text file is stored in the cache.
Receiving and exporting an Excel instruction, wherein the instruction carries one or more data identifications; deleting other text files except the text file corresponding to the data identifier carried in the instruction from the cache;
in practice, sometimes a user deletes the check after finishing checking the data to be exported, and deletes all text files except the text file corresponding to the data identifier carried in the instruction from the cache; the conversion of unnecessary text files into Excel files is avoided, and the unnecessary text files occupy too much cache space.
Reading the residual text files in the cache according to the data volume set each time, performing data format conversion on the file files read each time, and writing the generated Excel file into a storage medium;
in the fourth step, data format conversion is performed on the file, and the generated Excel file is the prior art, and chinese patent of CN200810057915.0 refers to this technology and discloses a device and method for exporting data in a database into an Excel file.
And in the fourth step, when reading the residual text files in the cache according to the set data volume each time, deleting the read text files from the cache after the reading is finished each time. By deleting the read text file from the cache in real time, the cache can be emptied after the reading is finished, so that the text file in the next Excel file exporting task can be timely stored in the cache.
And step five, repairing the Excel file to generate a file for the Excel program to read and open. Step five is the prior art, and chinese patent of CN200810057915.0 for reference discloses an apparatus and method for exporting data in a database into an Excel file.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and all simple modifications, changes and equivalent structural changes made to the above embodiment according to the technical spirit of the present invention still fall within the protection scope of the technical solution of the present invention.
Claims (4)
1. A method for exporting data in a database into an Excel file is characterized by comprising the following steps:
firstly, acquiring a data identifier to be exported in advance;
exporting corresponding data in the database into a text file according to the data identification, and storing the text file into a cache;
receiving and exporting an Excel instruction, wherein the instruction carries one or more data identifications; deleting other text files except the text file corresponding to the data identifier carried in the instruction from the cache;
reading the residual text files in the cache according to the data volume set each time, performing data format conversion on the file files read each time, and writing the generated Excel file into a storage medium;
and step five, repairing the Excel file to generate a file for the Excel program to read and open.
2. The method for exporting data in the database into an Excel file according to claim 1, wherein in the first step, the pre-obtaining of the identifier of the data to be exported includes: and acquiring the selection information of the front-end user on the data, and acquiring the data identifier corresponding to the selection information.
3. The method for exporting data in the database into an Excel file according to the claim 1 or 2, wherein in the second step, exporting the corresponding data in the database into a text file according to the data identification comprises: and inquiring corresponding data in the database according to the data identification, converting the inquired data into a text file, adding the data identification to the converted text file, and storing the text file into a cache.
4. The method for exporting data in the database into an Excel file according to claim 1 or 2, wherein in the fourth step, when reading the text file left in the cache according to the set data amount each time, the read text file is deleted from the cache after the reading is completed each time.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010063540.XA CN113138959A (en) | 2020-01-19 | 2020-01-19 | Method for exporting data in database into Excel file |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010063540.XA CN113138959A (en) | 2020-01-19 | 2020-01-19 | Method for exporting data in database into Excel file |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113138959A true CN113138959A (en) | 2021-07-20 |
Family
ID=76808844
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010063540.XA Pending CN113138959A (en) | 2020-01-19 | 2020-01-19 | Method for exporting data in database into Excel file |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113138959A (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101231665A (en) * | 2008-02-20 | 2008-07-30 | 中兴通讯股份有限公司 | Apparatus and method for educing data into Excel files from database |
CN106484805A (en) * | 2016-09-22 | 2017-03-08 | 联动优势电子商务有限公司 | A kind of data export method and data handling system |
US20190042641A1 (en) * | 2016-02-01 | 2019-02-07 | Global Software Innovation Pty Ltd. | Graph-Based Operations on an Entity-Relationship Database |
CN110008262A (en) * | 2019-02-02 | 2019-07-12 | 阿里巴巴集团控股有限公司 | A kind of data export method and device |
CN110096533A (en) * | 2019-04-30 | 2019-08-06 | 上海复繁信息科技有限公司 | The method that a kind of pair of atrial fibrillation Single diseases data carry out multi-dimensional query analysis |
-
2020
- 2020-01-19 CN CN202010063540.XA patent/CN113138959A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101231665A (en) * | 2008-02-20 | 2008-07-30 | 中兴通讯股份有限公司 | Apparatus and method for educing data into Excel files from database |
US20190042641A1 (en) * | 2016-02-01 | 2019-02-07 | Global Software Innovation Pty Ltd. | Graph-Based Operations on an Entity-Relationship Database |
CN106484805A (en) * | 2016-09-22 | 2017-03-08 | 联动优势电子商务有限公司 | A kind of data export method and data handling system |
CN110008262A (en) * | 2019-02-02 | 2019-07-12 | 阿里巴巴集团控股有限公司 | A kind of data export method and device |
CN110096533A (en) * | 2019-04-30 | 2019-08-06 | 上海复繁信息科技有限公司 | The method that a kind of pair of atrial fibrillation Single diseases data carry out multi-dimensional query analysis |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109739934B (en) | Difference set account checking method, medium, computer equipment and system | |
CN103377123B (en) | A kind of web page code automated testing method and device | |
CN102486772A (en) | Method and device for exporting data | |
CN112328631A (en) | Production fault analysis method and device, electronic equipment and storage medium | |
CN115221143A (en) | Cross-type migration operator-based multi-source big data processing method | |
CN110569230A (en) | Method, system and equipment for interconversion between database design model and design document | |
CN113138959A (en) | Method for exporting data in database into Excel file | |
CN111897828A (en) | Data batch processing implementation method, device, equipment and storage medium | |
CN106909623A (en) | A kind of data set and date storage method of supporting efficient mass data to analyze and retrieve | |
CN112052248A (en) | Audit big data processing method and system | |
CN115686493A (en) | Method for automatically generating interface control document by C language data structure code | |
CN115687490A (en) | Data export method and device, computer equipment and storage medium | |
CN115422180A (en) | Data verification method and system | |
CN114356454A (en) | Account checking data processing method, account checking data processing device, account checking data storage medium and program product | |
CN115577113A (en) | Knowledge graph platform | |
CN111241191A (en) | Database synchronization method and device | |
CN110580424A (en) | detection report automatic identification method, device and system for three-dimensional scanner | |
CN107085553B (en) | Input box testing method and device | |
CN110597828A (en) | Database changing method, device, equipment and storage medium | |
CN112783927B (en) | Database query method and system | |
CN114546261B (en) | Object movement optimization method and system in distributed object storage | |
CN115237781A (en) | Interface test method for dynamically associating file parameters | |
CN115600999A (en) | Experience document generation method, terminal and storage medium | |
CN117389986A (en) | Database compatibility evaluation method and device, electronic equipment and storage medium | |
CN115080566A (en) | Template-based automatic document generation method in QT environment |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210720 |