CN112784553A - Method and device for exporting data as Excel document - Google Patents

Method and device for exporting data as Excel document Download PDF

Info

Publication number
CN112784553A
CN112784553A CN202011627385.6A CN202011627385A CN112784553A CN 112784553 A CN112784553 A CN 112784553A CN 202011627385 A CN202011627385 A CN 202011627385A CN 112784553 A CN112784553 A CN 112784553A
Authority
CN
China
Prior art keywords
data
exported
fragment
excel document
server
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
Application number
CN202011627385.6A
Other languages
Chinese (zh)
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.)
Iol Wuhan Information Technology Co ltd
Original Assignee
Iol Wuhan 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 Iol Wuhan Information Technology Co ltd filed Critical Iol Wuhan Information Technology Co ltd
Priority to CN202011627385.6A priority Critical patent/CN112784553A/en
Publication of CN112784553A publication Critical patent/CN112784553A/en
Pending legal-status Critical Current

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
    • G06F40/174Form filling; Merging
    • 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
    • G06F16/2433Query languages

Landscapes

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

Abstract

The invention provides a method and a device for exporting data as an Excel document, wherein the method comprises the following steps: fragmenting the data to be exported according to the preset number of each piece of data to be exported to obtain the serial number of the current fragment; sending the preset number and the serial number of the current fragment to a server, so that the server can retrieve the data to be exported of the current fragment from a database according to the preset number and the serial number of the current fragment; receiving the data to be exported of the current fragment returned by the server until the data to be exported of all fragments is received; and generating an Excel document according to the data to be exported of all the fragments by using a third-party extension tool library. The embodiment ensures the integrity and accuracy of data, the client is not easy to cause blockage, and the pressure of the server is reduced.

Description

Method and device for exporting data as Excel document
Technical Field
The invention relates to the technical field of big data export, in particular to a method and a device for exporting data into an Excel document.
Background
In practical applications, it is often encountered that a large data needs to be exported as an Excel document. The generation of the Excel document is usually completed by a back end.
Due to the limited performance of the personal computer, all data can be exported at one time under the condition of large data volume, and the Excel document is difficult to generate, so that the time consumption is long, and the long-time blocking of the client browser can be caused.
Disclosure of Invention
The invention provides a method and a device for exporting data into an Excel document, which are used for solving the defect that the Excel document exporting by a client consumes long time and is blocked in the prior art, and realizing aggregation generation of the Excel document after data are exported in batches.
The invention provides a method for exporting data as an Excel document, which comprises the following steps:
fragmenting the data to be exported according to the preset number of each piece of data to be exported to obtain the serial number of the current fragment;
sending the preset number and the serial number of the current fragment to a server, so that the server can retrieve the data to be exported of the current fragment from a database according to the preset number and the serial number of the current fragment;
receiving the data to be exported of the current fragment returned by the server until the data to be exported of all fragments is received;
and generating an Excel document according to the data to be exported of all the fragments by using a third-party extension tool library.
According to the method for exporting data into the Excel document, the index of the first data to be exported in the current fragment is calculated by the server according to the preset number of pieces and the sequence number of the current fragment, and the index of the first data to be exported is retrieved according to the preset number of pieces and the index of the first data to be exported.
According to the method for exporting data into the Excel document, the step of receiving the data to be exported of the current fragment returned by the server until the data to be exported of all fragments is received comprises the following steps:
receiving data to be exported of the current fragment returned by the server;
if the number of the data to be exported of the current fragment is equal to the preset number, continuing to send the preset number and the serial number of the next fragment of the current fragment to a server, so that the server returns the data to be exported of the next fragment according to the preset number and the serial number of the next fragment;
and if the number of the data to be exported of the current fragment is not equal to the preset number, acquiring that the data to be exported of all the fragments are received.
According to the method for exporting data into the Excel document, which is provided by the invention, the Excel document is generated according to the data to be exported of all the fragments by using the third-party extension tool library, and the method comprises the following steps:
if the total number of the data to be exported is known, calculating the total number of the data to be exported which are sliced according to the preset number and the total number;
according to the total number of the fragments, parallel downloading is carried out on the data to be exported of all the fragments;
and generating an Excel document according to the downloaded data to be exported of all the fragments by using a third-party extension tool library.
According to the method for exporting data into the Excel document, which is provided by the invention, the Excel document is generated according to the data to be exported of all the fragments by using the third-party extension tool library, and the method comprises the following steps:
downloading the data to be exported of each fragment, and if the data to be exported of any fragment fails to be downloaded, re-downloading the data to be exported of the fragment;
and generating an Excel document according to the data to be exported of the re-downloaded fragments by using a third party extension tool library.
According to the method for exporting data into the Excel document, which is provided by the invention, the Excel document is generated according to the data to be exported of all the fragments by using the third-party extension tool library, and the method comprises the following steps:
checking the data to be exported of each fragment, and if the data to be exported of any fragment is abnormal, sending the preset number of pieces and the serial number of the fragment to a server so that the server can return the data to be exported of the fragment again according to the preset number of pieces and the serial number of the fragment;
and generating an Excel document according to the data to be exported of the fragment returned again by the server by using a third-party extension tool library.
According to the method for exporting data into the Excel document, which is provided by the invention, the Excel document is generated according to the data to be exported of all the fragments by using the third-party extension tool library, and the method comprises the following steps:
if the pause operation of the user is acquired in the downloading process of the data to be exported of the fragment, the downloading of the data to be exported of the fragment is paused;
if the starting downloading operation of the user on the data to be exported which is temporarily downloaded is obtained, continuing downloading from the data to be exported of the fragment which is temporarily downloaded;
and generating an Excel document according to the to-be-exported data of all the downloaded fragments by using a third party extension tool library.
The invention also provides a device for exporting data as an Excel document, which comprises the following steps:
the fragmentation module is used for fragmenting the data to be exported according to the preset number of each piece of data to be exported to acquire the serial number of the current fragmentation;
the sending module is used for sending the preset number and the serial number of the current fragment to a server so that the server can retrieve the data to be exported of the current fragment from a database according to the preset number and the serial number of the current fragment;
the receiving module is used for receiving the data to be exported of the current fragment returned by the server until the data to be exported of all fragments is received;
and the generating module is used for generating an Excel document according to the to-be-exported data of all the fragments by using a third-party extension tool library.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the steps of the method for exporting data into an Excel document.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of exporting data as an Excel document according to any of the above.
According to the method and the device for exporting data into the Excel document, provided by the invention, the data to be exported is exported after being partitioned according to a certain size, and all the partitioned data are summarized and integrated into the Excel document by the client after all the data are exported, so that the integrity and the accuracy of the data are ensured; the processing capacity of the client is utilized, the data are exported in combination with the fragments, the data are automatically integrated to generate an Excel document, the client is not easy to jam, and the pressure of the server is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
FIG. 1 is a schematic flow chart of a method for exporting data into an Excel document according to the present invention;
FIG. 2 is a schematic structural diagram of an apparatus for exporting data into an Excel document according to the present invention;
fig. 3 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The following describes a method for exporting data into an Excel document according to the present invention with reference to fig. 1, including: step 101, fragmenting data to be exported according to the preset number of each piece of data to be exported, and acquiring the serial number of the current fragment;
the data to be exported is data needing to be exported as an Excel document, and is data in a table with pages in the current Web page. The title of the table is obtained and stored using JavaScript, and is used as the header title line dataTitle of Excel, and the table body array dataMain is defined. The dataTitle header row is added to the beginning of the table body dataMain array.
The client-side fragments the data to be exported from front to back in sequence, so that the number of the data to be exported in each fragment is equal to the preset number. And numbering each fragment according to the sequence of the data to be exported in each fragment in the table. For example, if the data to be exported is divided into 30 pieces, the sequence numbers of the pieces are 1 to 30 in sequence.
102, sending the preset number and the serial number of the current fragment to a server, so that the server retrieves the data to be derived of the current fragment from a database according to the preset number and the serial number of the current fragment;
the client side sequentially sends the serial number and the preset number of each fragment to the server side. And defining the number of the data to be exported in each fragment as a preset number limit, and defining the sequence number of the current fragment as a page. And sending the limit and the page to an interface address of a current page table of the server. The server uses SQL (Structured Query Language) Query statements to retrieve data to be exported of the current fragment from the database according to the limit and the page, and returns the data to be exported to the client.
103, receiving the data to be exported of the current fragment returned by the server until the data to be exported of all fragments is received;
and after the client receives the returned data to be exported of the current fragment, circularly pushing the data to the table body array dataMain for storage. And then continuing to send the + + page and the limit to the server side until the to-be-exported data of all the fragments is received.
And 104, generating an Excel document according to the to-be-exported data of all the fragments by using a third-party extended tool library.
And generating an Excel document by using a third-party extension tool library such as SheetJS and using a table body array dataMain which is already complete Excel data, and popping up a download box after execution. And simultaneously releasing the data in the deleted dataMain.
In the embodiment, the data to be exported is exported after being fragmented according to a certain size, and all fragments are summarized and integrated into the Excel document by the client after all the data are exported, so that the integrity and accuracy of the data are ensured; the processing capacity of the client is utilized, the data are exported in combination with the fragments, the data are automatically integrated to generate an Excel document, the client is not easy to jam, and the pressure of the server is reduced.
On the basis of the foregoing embodiment, in this embodiment, the server calculates, according to the preset number and the sequence number of the current segment, an index of the first to-be-derived data in the current segment, and retrieves the to-be-derived data according to the index of the first to-be-derived data and the preset number.
Specifically, the server side queries data in the table after receiving a data request of the client side. When the database is queried, the limit and the page parameters in the SQL query statement are replaced by the received limit and page. And the SQL query statement calculates the index of the first data to be derived in the current fragment to be (page-1) limit according to the preset number limit and the page of the sequence number of the current fragment, and retrieves the data to be derived of the current fragment according to the (page-1) limit and the limit. And returning the retrieved data to be exported of the current fragment to the client.
On the basis of the foregoing embodiment, in this embodiment, the receiving the data to be exported of the current segment returned by the server until receiving the data to be exported of all segments includes: receiving data to be exported of the current fragment returned by the server; if the number of the data to be exported of the current fragment is equal to the preset number, continuing to send the preset number and the serial number of the next fragment of the current fragment to a server, so that the server returns the data to be exported of the next fragment according to the preset number and the serial number of the next fragment; and if the number of the data to be exported of the current fragment is not equal to the preset number, acquiring that the data to be exported of all the fragments are received.
Specifically, if the number of pieces of data to be exported in the current fragment returned by the server is equal to limit, + + page and limit are continuously sent to the server. And until the data strip degree of the return data is judged to be not equal to the limit, acquiring that all the data to be exported are pulled out.
On the basis of the foregoing embodiment, in this embodiment, the generating an Excel document according to the to-be-exported data of all segments by using a third-party extension tool library includes: if the total number of the data to be exported is determined, calculating the total number of the data to be exported which are sliced according to the preset number and the total number; according to the total number of the fragments, parallel downloading is carried out on the data to be exported of all the fragments; and generating an Excel document according to the downloaded data to be exported of all the fragments by using a third-party extension tool library.
Specifically, when the total number of pieces of data to be exported is known by the client, the total number totalPages of shards of data to be exported is calculated, totalNum% limit, 0? (totalNum/limit) + 1. At this time, parallel downloading is started, and a plurality of threads are used for sending totalPages in parallel to request parallel downloading. And when the data volume is large, downloading the plurality of fragments in parallel to accelerate downloading. When the client does not start the parallel downloading, the streaming downloading is adopted. The total number of data to be derived is not determined at this time.
According to the embodiment, different fragments are downloaded in parallel through multiple threads, so that the downloading efficiency is improved, and the downloading time is reduced.
On the basis of the foregoing embodiments, in this embodiment, the generating an Excel document according to the to-be-exported data of all the segments by using the third-party extension tool library includes: downloading the data to be exported of each fragment, and if the data to be exported of any fragment fails to be downloaded, re-downloading the data to be exported of the fragment; and generating an Excel document according to the data to be exported of the re-downloaded fragments by using a third party extension tool library.
Specifically, the existing Excel export method needs to download from the data starting position due to the reasons of large data volume, network fluctuation, intermediate disconnection, link timeout and the like. When the downloading of the data to be exported of the fragments fails, independent retry can be performed on a single fragment in the acquired dataMain data according to the autonomous selection of the user, and other fragments do not need to be downloaded again.
According to the embodiment, the situation that various data export fails due to network reasons and the like when big data are exported is reduced, a large amount of resources and time cost are saved, and the speed and the quality of exporting the big data are improved.
On the basis of the foregoing embodiments, in this embodiment, the generating an Excel document according to the to-be-exported data of all the segments by using the third-party extension tool library includes: checking the data to be exported of each fragment, and if the data to be exported of any fragment is abnormal, sending the preset number of pieces and the serial number of the fragment to a server so that the server can return the data to be exported of the fragment again according to the preset number of pieces and the serial number of the fragment; and generating an Excel document according to the data to be exported of the fragment returned again by the server by using a third-party extension tool library.
Specifically, if the data to be exported of a certain fragment is in error due to network and other reasons, the data to be exported of each fragment is checked to obtain data abnormality, and the preset number and sequence number of the abnormal fragments are continuously sent to the server to export the abnormal fragments again.
On the basis of the foregoing embodiments, in this embodiment, the generating an Excel document according to the to-be-exported data of all the segments by using the third-party extension tool library includes: if the pause operation of the user is acquired in the downloading process of the data to be exported of the fragment, the downloading of the data to be exported of the fragment is paused; if the starting downloading operation of the user on the data to be exported which is temporarily downloaded is obtained, continuing downloading from the data to be exported of the fragment which is temporarily downloaded; and generating an Excel document according to the to-be-exported data of all the downloaded fragments by using a third party extension tool library.
Specifically, if the downloading of the segment is suspended in the middle of the downloading process, the downloading may be continued from the position of the segment where the downloading is suspended.
The device for exporting data into an Excel document according to the present invention is described below, and the device for exporting data into an Excel document described below and the method for exporting data into an Excel document described above may be referred to correspondingly.
As shown in fig. 2, the apparatus includes a fragmentation module 201, a sending module 202, a receiving module 203, and a generating module 204; wherein:
the fragmentation module 201 is configured to fragment the data to be exported according to a preset number of each piece of data to be exported, and obtain a serial number of a current fragmentation;
the client-side fragments the data to be exported from front to back in sequence, so that the number of the data to be exported in each fragment is equal to the preset number. And numbering each fragment according to the sequence of the data to be exported in each fragment in the table.
The sending module 202 is configured to send the preset number and the serial number of the current segment to a server, so that the server retrieves data to be derived of the current segment from a database according to the preset number and the serial number of the current segment;
the client side sequentially sends the serial number and the preset number of each fragment to the server side. And defining the number of the data to be exported in each fragment as a preset number limit, and defining the sequence number of the current fragment as a page. And sending the limit and the page to an interface address of a current page table of the server. And the server uses SQL query statements to retrieve the data to be exported of the current fragment from the database according to the limit and the page and returns the data to the client.
The receiving module 203 is configured to receive the to-be-exported data of the current segment returned by the server until the to-be-exported data of all segments is received;
and after the client receives the returned data to be exported of the current fragment, circularly pushing the data to the table body array dataMain for storage. And then continuing to send the + + page and the limit to the server side until the to-be-exported data of all the fragments is received.
The generating module 204 is configured to generate an Excel document according to the to-be-exported data of all the fragments by using a third-party extension tool library.
And generating an Excel document by using a third-party extension tool library such as SheetJS and using a table body array dataMain which is already complete Excel data, and popping up a download box after execution. And simultaneously releasing the data in the deleted dataMain.
In the embodiment, the data to be exported is exported after being fragmented according to a certain size, and all fragments are summarized and integrated into the Excel document by the client after all the data are exported, so that the integrity and accuracy of the data are ensured; the processing capacity of the client is utilized, the data are exported in combination with the fragments, the data are automatically integrated to generate an Excel document, the client is not easy to jam, and the pressure of the server is reduced.
On the basis of the foregoing embodiment, in this embodiment, the server calculates, according to the preset number and the sequence number of the current segment, an index of the first to-be-derived data in the current segment, and retrieves the to-be-derived data according to the index of the first to-be-derived data and the preset number.
On the basis of the foregoing embodiment, the receiving module in this embodiment is configured to: receiving data to be exported of the current fragment returned by the server; if the number of the data to be exported of the current fragment is equal to the preset number, continuing to send the preset number and the serial number of the next fragment of the current fragment to a server, so that the server returns the data to be exported of the next fragment according to the preset number and the serial number of the next fragment; and if the number of the data to be exported of the current fragment is not equal to the preset number, acquiring that the data to be exported of all the fragments are received.
On the basis of the foregoing embodiment, the generating module in this embodiment is configured to: if the total number of the data to be exported is determined, calculating the total number of the data to be exported which are sliced according to the preset number and the total number; according to the total number of the fragments, parallel downloading is carried out on the data to be exported of all the fragments; and generating an Excel document according to the downloaded data to be exported of all the fragments by using a third-party extension tool library.
On the basis of the foregoing embodiments, the generating module in this embodiment is configured to: downloading the data to be exported of each fragment, and if the data to be exported of any fragment fails to be downloaded, re-downloading the data to be exported of the fragment; and generating an Excel document according to the data to be exported of the re-downloaded fragments by using a third party extension tool library.
On the basis of the foregoing embodiments, the generating module in this embodiment is configured to: checking the data to be exported of each fragment, and if the data to be exported of any fragment is abnormal, sending the preset number of pieces and the serial number of the fragment to a server so that the server can return the data to be exported of the fragment again according to the preset number of pieces and the serial number of the fragment; and generating an Excel document according to the data to be exported of the fragment returned again by the server by using a third-party extension tool library.
On the basis of the foregoing embodiments, the generating module in this embodiment is configured to: if the pause operation of the user is acquired in the downloading process of the data to be exported of the fragment, the downloading of the data to be exported of the fragment is paused; if the starting downloading operation of the user on the data to be exported which is temporarily downloaded is obtained, continuing downloading from the data to be exported of the fragment which is temporarily downloaded; and generating an Excel document according to the to-be-exported data of all the downloaded fragments by using a third party extension tool library.
Fig. 3 illustrates a physical structure diagram of an electronic device, which may include, as shown in fig. 3: a processor (processor)310, a communication Interface (communication Interface)320, a memory (memory)330 and a communication bus 340, wherein the processor 310, the communication Interface 320 and the memory 330 communicate with each other via the communication bus 340. Processor 310 may invoke logic instructions in memory 330 to perform a method of exporting data as an Excel document, the method comprising: fragmenting the data to be exported according to the preset number of each piece of data to be exported to obtain the serial number of the current fragment; sending the preset number and the serial number of the current fragment to a server, so that the server can retrieve the data to be exported of the current fragment from a database according to the preset number and the serial number of the current fragment; receiving the data to be exported of the current fragment returned by the server until the data to be exported of all fragments is received; and generating an Excel document according to the data to be exported of all the fragments by using a third-party extension tool library.
In addition, the logic instructions in the memory 330 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, including a computer program stored on a non-transitory computer readable storage medium, the computer program including program instructions, which when executed by a computer, enable the computer to perform the method for exporting data into an Excel document, provided by the above methods, the method including: fragmenting the data to be exported according to the preset number of each piece of data to be exported to obtain the serial number of the current fragment; sending the preset number and the serial number of the current fragment to a server, so that the server can retrieve the data to be exported of the current fragment from a database according to the preset number and the serial number of the current fragment; receiving the data to be exported of the current fragment returned by the server until the data to be exported of all fragments is received; and generating an Excel document according to the data to be exported of all the fragments by using a third-party extension tool library.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor, implements the method for exporting data into an Excel document provided in the above, the method comprising: fragmenting the data to be exported according to the preset number of each piece of data to be exported to obtain the serial number of the current fragment; sending the preset number and the serial number of the current fragment to a server, so that the server can retrieve the data to be exported of the current fragment from a database according to the preset number and the serial number of the current fragment; receiving the data to be exported of the current fragment returned by the server until the data to be exported of all fragments is received; and generating an Excel document according to the data to be exported of all the fragments by using a third-party extension tool library.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for exporting data as an Excel document, comprising the following steps:
fragmenting the data to be exported according to the preset number of each piece of data to be exported to obtain the serial number of the current fragment;
sending the preset number and the serial number of the current fragment to a server, so that the server can retrieve the data to be exported of the current fragment from a database according to the preset number and the serial number of the current fragment;
receiving the data to be exported of the current fragment returned by the server until the data to be exported of all fragments is received;
and generating an Excel document according to the data to be exported of all the fragments by using a third-party extension tool library.
2. The method according to claim 1, wherein the index of the first data to be exported in the current segment is calculated by the server according to the preset number of pieces and the sequence number of the current segment, and the data to be exported in the current segment is retrieved according to the index of the first data to be exported and the preset number of pieces.
3. The method for exporting data as an Excel document according to claim 1, wherein the receiving the data to be exported of the current segment returned by the server until the data to be exported of all segments is received comprises:
receiving data to be exported of the current fragment returned by the server;
if the number of the data to be exported of the current fragment is equal to the preset number, continuing to send the preset number and the serial number of the next fragment of the current fragment to a server, so that the server returns the data to be exported of the next fragment according to the preset number and the serial number of the next fragment;
and if the number of the data to be exported of the current fragment is not equal to the preset number, acquiring that the data to be exported of all the fragments are received.
4. The method for exporting data into an Excel document according to any one of claims 1 to 3, wherein the generating an Excel document from the data to be exported of all the shards by using a third party extension tool library comprises:
if the total number of the data to be exported is known, calculating the total number of the data to be exported which are sliced according to the preset number and the total number;
according to the total number of the fragments, parallel downloading is carried out on the data to be exported of all the fragments;
and generating an Excel document according to the downloaded data to be exported of all the fragments by using a third-party extension tool library.
5. The method for exporting data into an Excel document according to any one of claims 1 to 3, wherein the generating an Excel document from the data to be exported of all the shards by using a third party extension tool library comprises:
downloading the data to be exported of each fragment, and if the data to be exported of any fragment fails to be downloaded, re-downloading the data to be exported of the fragment;
and generating an Excel document according to the data to be exported of the re-downloaded fragments by using a third party extension tool library.
6. The method for exporting data into an Excel document according to any one of claims 1 to 3, wherein the generating an Excel document from the data to be exported of all the shards by using a third party extension tool library comprises:
checking the data to be exported of each fragment, and if the data to be exported of any fragment is abnormal, sending the preset number of pieces and the serial number of the fragment to a server so that the server can return the data to be exported of the fragment again according to the preset number of pieces and the serial number of the fragment;
and generating an Excel document according to the data to be exported of the fragment returned again by the server by using a third-party extension tool library.
7. The method for exporting data into an Excel document according to any one of claims 1 to 3, wherein the generating an Excel document from the data to be exported of all the shards by using a third party extension tool library comprises:
if the pause operation of the user is acquired in the downloading process of the data to be exported of the fragment, the downloading of the data to be exported of the fragment is paused;
if the starting downloading operation of the user on the data to be exported which is temporarily downloaded is obtained, continuing downloading from the data to be exported of the fragment which is temporarily downloaded;
and generating an Excel document according to the to-be-exported data of all the downloaded fragments by using a third party extension tool library.
8. An apparatus for exporting data as an Excel document, comprising:
the fragmentation module is used for fragmenting the data to be exported according to the preset number of each piece of data to be exported to acquire the serial number of the current fragmentation;
the sending module is used for sending the preset number and the serial number of the current fragment to a server so that the server can retrieve the data to be exported of the current fragment from a database according to the preset number and the serial number of the current fragment;
the receiving module is used for receiving the data to be exported of the current fragment returned by the server until the data to be exported of all fragments is received;
and the generating module is used for generating an Excel document according to the to-be-exported data of all the fragments by using a third-party extension tool library.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the program performs the steps of the method of exporting data as an Excel document according to any of claims 1 to 7.
10. A non-transitory computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the steps of the method of exporting data as an Excel document according to anyone of the claims 1 to 7.
CN202011627385.6A 2020-12-31 2020-12-31 Method and device for exporting data as Excel document Pending CN112784553A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011627385.6A CN112784553A (en) 2020-12-31 2020-12-31 Method and device for exporting data as Excel document

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011627385.6A CN112784553A (en) 2020-12-31 2020-12-31 Method and device for exporting data as Excel document

Publications (1)

Publication Number Publication Date
CN112784553A true CN112784553A (en) 2021-05-11

Family

ID=75754563

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011627385.6A Pending CN112784553A (en) 2020-12-31 2020-12-31 Method and device for exporting data as Excel document

Country Status (1)

Country Link
CN (1) CN112784553A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103634361A (en) * 2012-08-28 2014-03-12 腾讯科技(深圳)有限公司 Method and apparatus for downloading file
CN106657213A (en) * 2016-09-14 2017-05-10 深圳峰创智诚科技有限公司 File transmission method and device
CN110851446A (en) * 2019-11-07 2020-02-28 苏州达家迎信息技术有限公司 Data table generation method and device, computer equipment and storage medium
CN111259038A (en) * 2020-01-16 2020-06-09 北京思特奇信息技术股份有限公司 Database query and data export method, system, medium and equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103634361A (en) * 2012-08-28 2014-03-12 腾讯科技(深圳)有限公司 Method and apparatus for downloading file
CN106657213A (en) * 2016-09-14 2017-05-10 深圳峰创智诚科技有限公司 File transmission method and device
CN110851446A (en) * 2019-11-07 2020-02-28 苏州达家迎信息技术有限公司 Data table generation method and device, computer equipment and storage medium
CN111259038A (en) * 2020-01-16 2020-06-09 北京思特奇信息技术股份有限公司 Database query and data export method, system, medium and equipment

Similar Documents

Publication Publication Date Title
US10515064B2 (en) Key-value storage system including a resource-efficient index
CN109831487B (en) Fragmented file verification method and terminal equipment
CN105160252B (en) A kind of detection method and device of SQL injection attacks
WO2018036549A1 (en) Distributed database query method and device, and management system
CN108228799B (en) Object index information storage method and device
TW201512866A (en) Method, system, browser and proxy server for web page loading
CN111512283B (en) Radix estimation in a database
US20220335014A1 (en) System and method for random-access manipulation of compacted data files
CN103684911A (en) Website online user statistical method and device
CN103324713A (en) Data processing method and device in multistage server and data processing system
US10025346B2 (en) Timestamp alignment across a plurality of computing devices
CN110825742B (en) Data paging retrieval method and device, electronic equipment and storage medium
CN112307062A (en) Database aggregation query method, device and system
CN107885634B (en) Method and device for processing abnormal information in monitoring
CN113535226B (en) Application downloading method, terminal, server, computer device and storage medium
CN112416967B (en) Data paging query method and device, electronic equipment and storage medium
CN111966682B (en) White list protection matching method, system, terminal and storage medium
CN112784553A (en) Method and device for exporting data as Excel document
CN105975498A (en) Data query method, device and system
US20210365520A1 (en) Webpage loading method, intermediate server and webpage loading system
CN110765125B (en) Method and device for storing data
CN109213972B (en) Method, device, equipment and computer storage medium for determining document similarity
CN111339170A (en) Data processing method and device, computer equipment and storage medium
CN115827922A (en) Visual analysis processing method and system based on wind power data and computer equipment
CN110851437A (en) Storage method, device and equipment

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