Excel file downloading method, Excel file uploading method and related devices
By receiving download requests and using POJO classes and annotations to generate Excel files, the problems of complex and inefficient downloading of Excel files in the existing technology are solved, and an efficient and flexible Excel file download process is realized.
Patent Information
- Application Number
- CN202411132082.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-11-22
AI Technical Summary
Existing Excel file download methods are complex and inefficient, especially when the field order or name changes, it requires rewriting the mapping logic, resulting in inefficient downloads.
By receiving download requests, obtaining annotations on POJO class and POJO class attributes, generating Excel files based on this information, realizing the mapping relationship between attributes and column names, and generating Excel files, avoiding the step of uploading empty template files first, and improving Download efficiency and flexibility.
It realizes efficient Excel file download, reduces development complexity and efficiency, and allows flexible changes to the annotations on POJO class attributes to generate different Excel files according to business needs.
Smart Images

Figure CN119011569A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data transmission, and in particular to an Excel file downloading method, an upload method and related devices. Background Art
[0002] With the rapid development of the supply chain finance market, more and more companies are beginning to adopt digital tools to optimize their business processes. Among the many digital tools, Excel files are widely used due to their powerful data processing capabilities and broad user base.
[0003] At present, in the process of downloading Excel files, users are usually required to upload a template file first, and parse the template file to determine which cells contain placeholders that need to be replaced. Then the back-end server converts the data in the database into key-value pairs, with the keys corresponding to the placeholders in the template file, so as to fill in the template and generate an Excel file. However, downloading Excel files in this way requires additional mapping logic to match the fields in the template file with the data in the database. On the one hand, the file generation process involved is relatively complicated. On the other hand, when the field order or field name in the template file changes, the mapping logic needs to be rewritten, which makes the download efficiency low.
[0004] Therefore, how to improve the downloading efficiency of Excel files becomes a problem that needs to be solved. Summary of the invention
[0005] Based on the above problems, the present application provides an Excel file downloading method, an upload method and related devices, which can improve the downloading efficiency of Excel files.
[0006] The embodiments of the present application disclose the following technical solutions:
[0007] In a first aspect, an embodiment of the present application provides a method for downloading an Excel file, the method comprising:
[0008] Receive the download request of Excel file;
[0009] Based on the download request, a POJO class corresponding to the download request and annotations on the POJO class attributes are obtained; the POJO class is used to represent the data structure of the Excel file, and the annotations on the POJO class attributes are used to define a mapping relationship between the attributes and the column names of the Excel file;
[0010] Generate an Excel file based on the POJO class and the annotations on the POJO class attributes;
[0011] Output the Excel file.
[0012] Optionally, the download request includes format information of the Excel file; the format information of the Excel file includes at least one of a table style, a font style and a cell format;
[0013] The generating of the Excel file based on the annotations on the POJO class and the POJO class attributes includes:
[0014] An Excel file is generated based on the format information of the Excel file, the POJO class and the annotations on the POJO class attributes.
[0015] Optionally, obtaining the POJO class and annotations on the POJO class attributes corresponding to the download request based on the download request includes:
[0016] In the case where the download request comes from the internal network, based on the download request, obtaining the POJO class and annotations on the POJO class attributes corresponding to the download request from the internal network disk array;
[0017] In the case where the download request comes from an external network, based on the download request, the POJO class and annotations on the POJO class attributes corresponding to the download request are obtained from an external storage medium; the intranet disk array and the external storage medium have data backup.
[0018] In a second aspect, an embodiment of the present application provides a method for uploading an Excel file, the method comprising:
[0019] Receive an Excel file upload request; the Excel file upload request includes the Excel file to be uploaded;
[0020] Based on the predefined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes, the Excel file to be uploaded is stored.
[0021] Optionally, after reading the Excel file to be uploaded, the method further includes:
[0022] Based on the predefined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes, each row of data in the Excel file to be uploaded is verified through a listener.
[0023] Optionally, storing the Excel file to be uploaded includes:
[0024] When the Excel file upload request comes from the internal network, storing the Excel file to be uploaded in the internal network disk array;
[0025] When the Excel file upload request comes from an external network, storing the Excel file to be uploaded in an external storage medium;
[0026] The internal network disk array and the external storage medium perform data mutual backup via a preset synchronization mechanism.
[0027] In a third aspect, an embodiment of the present application provides a device for downloading an Excel file, the device comprising: a first receiving module, an acquiring module, a generating module and an output module;
[0028] The first receiving module is used to receive a download request for an Excel file;
[0029] The acquisition module is used to acquire the POJO class corresponding to the download request and the annotations on the POJO class attributes based on the download request; the POJO class is used to represent the data structure of the Excel file, and the annotations on the POJO class attributes are used to define the mapping relationship between the attributes and the column names of the Excel file;
[0030] The generating module is used to generate an Excel file based on the POJO class and the annotations on the POJO class attributes;
[0031] The output module is used to output the Excel file.
[0032] In a fourth aspect, an embodiment of the present application provides an Excel file uploading device, the device comprising: a second receiving module and a storage module;
[0033] The second receiving module is used to receive an Excel file upload request; the Excel file upload request includes an Excel file to be uploaded;
[0034] The storage module is used to store the Excel file to be uploaded based on the predefined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes.
[0035] In a fifth aspect, an embodiment of the present application provides an intranet and extranet data transmission system, the system comprising: an external storage medium, an intranet disk array, and a processor;
[0036] The external storage medium, the intranet disk array and the processor are in communication connection; the external storage medium and the intranet disk array perform data mutual backup through a preset synchronization mechanism;
[0037] The external storage medium is used to store the external network data transmission program code and transmit the external network data transmission program code to the processor;
[0038] The intranet disk array is used to store the intranet data transmission program code and transmit the intranet data transmission program code to the processor;
[0039] The processor is used to execute the steps of the Excel file downloading method described in any implementation manner of the first aspect, or execute the steps of the Excel file uploading method described in any implementation manner of the second aspect according to the external network data transmission program code and the internal network data transmission program code.
[0040] Optionally, the external storage medium includes an external cloud storage and / or an external local storage.
[0041] Compared with the prior art, this application has the following beneficial effects:
[0042] The embodiment of the present application provides a method for downloading an Excel file, in which, first, a download request for an Excel file is received; then, based on the download request, the POJO class corresponding to the download request and the annotations on the POJO class attributes are obtained; the POJO class is used to represent the data structure of the Excel file, and the annotations on the POJO class attributes are used to define the mapping relationship between the attributes and the column names of the Excel file; then, based on the POJO class and the annotations on the POJO class attributes, an Excel file is generated; finally, the Excel file is output. Thus, according to the pre-set POJO class and the annotations on the POJO class attributes, the mapping of the POJO object to the content in the Excel file is completed, and the Excel file is generated, thereby realizing the download of the Excel file. In the process of downloading the Excel file, there is no need to upload an empty template file first, and the download efficiency is high; according to different business needs and scenarios, the same POJO class can be used to change the annotations on the POJO class attributes to generate different Excel files, and the flexibility of downloading Excel files is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 A flow chart of a method for downloading an Excel file provided in an embodiment of the present application;
[0045] Figure 2 An Excel file download flow chart provided for an embodiment of the present application;
[0046] Figure 3 A flowchart of an Excel file uploading method provided in an embodiment of the present application;
[0047] Figure 4 An Excel file upload flow chart provided in an embodiment of the present application;
[0048] Figure 5 A schematic diagram of a device for downloading an Excel file provided in an embodiment of the present application;
[0049] Figure 6 A schematic diagram of an Excel file uploading device provided in an embodiment of the present application;
[0050] Figure 7 A schematic diagram of an intranet and extranet data transmission system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] The Excel file downloading method, uploading method and related devices provided in the present application can be used in the field of data transmission. The above is only an example and does not limit the application field of the Excel file downloading method, uploading method and related devices provided in the present application.
[0052] The terms "first", "second", "third" and "fourth" etc. in the specification, claims and drawings of this application are used to distinguish different objects rather than to limit a specific order.
[0053] In the embodiments of the present application, the words "as an example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "as an example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the words "as an example" or "for example" is intended to present the relevant concepts in a specific way.
[0054] The terms used in the implementation section of this application are only used to explain the specific embodiments of this application and are not intended to limit this application.
[0055] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0056] See also Figure 1, which is a flow chart of a method for downloading an Excel file provided in an embodiment of the present application, the method comprising:
[0057] S101: receiving a download request for an Excel file.
[0058] The user can send a specific download request to the server through a terminal device, such as a computer or a smart phone, to request downloading of the required Excel file.
[0059] Specifically, the user can operate through the platform or application software installed on the terminal device to generate a download request for the Excel file, wherein the operations performed may include, for example, selecting a corresponding download option, or entering a corresponding download instruction, etc.; then, the download request is sent to the server through the network, so that the server receives the download request for the Excel file.
[0060] Optionally, the download request may include format information of the Excel file, wherein the format information of the Excel file includes but is not limited to at least one of a table style, a font style, and a cell style.
[0061] For example, you can use a Java-based Excel processing tool such as EasyExcel to write Excel files. In the process of downloading Excel files, users can add the format information of the Excel file to the download request through the Application Programming Interface (API) provided by EasyExcel to customize the format of the downloaded Excel file. For example, you can set the table style of the Excel file through TableStyle, set the cell style of the cells in the Excel file through WriteCellStyle, and set the font style of the font in the Excel file through WriteFont.
[0062] S102: Based on the download request, obtain the POJO class corresponding to the download request and the annotations on the POJO class attributes.
[0063] In Java development, POJO (Plain Old Java Object) classes are usually used to represent data models in business logic. In this embodiment, the data model is also the data structure of the Excel file. In order to facilitate the processing of data in the Excel file, we can use annotations to mark the properties of the POJO class, thereby corresponding these properties to the column names in the Excel file and defining the mapping relationship between the properties and the column names of the Excel file. In this way, when downloading the Excel file, data can be exported from the POJO object to the Excel file more conveniently.
[0064] As an example, during the development phase, you can pre-define a POJO class based on the data structure of the Excel file, and add appropriate annotations to each attribute that needs to be mapped, such as adding the annotation @ExcelColumn.
[0065] Optionally, if the download request is initiated by an intranet user, that is, the download request comes from the internal network, then based on the download request, the POJO class and the annotations on the POJO class attributes corresponding to the download request can be obtained from the intranet disk array; if the download request is initiated by an external network user, that is, the download request comes from the external network, then based on the download request, the POJO class and the annotations on the POJO class attributes corresponding to the download request can be obtained from the external storage medium. Among them, the external storage medium can include at least one of a cloud storage and an external local storage; the intranet disk array and the external storage medium can perform data backup when either of them receives a newly uploaded Excel file, or can perform data backup in real time or at a scheduled time.
[0066] Therefore, the file only needs to be transmitted once through the entry bandwidth to achieve data backup between the intranet disk array and the external storage medium. Internal and external network users can download Excel files through different network paths, thereby reducing the delay and bandwidth consumption caused by cross-network access, maximizing the saving of entry bandwidth, and thus improving the download efficiency of Excel files.
[0067] S103: Generate an Excel file based on the annotations on the POJO class and the POJO class attributes.
[0068] As an example, you can use a Java-based Excel processing tool such as EasyExcel to automatically match the column names and data types in the Excel file according to the annotations on the POJO class and the POJO class attributes, realize dynamic mapping of data to the Excel file, complete the mapping of the POJO object to the content in the Excel file, and generate the Excel file. In this way, you only need to perform a simple data conversion process to generate the Excel file.
[0069] Optionally, when the download request includes the format information of the Excel file, an Excel file in the required format can be generated based on the format information of the Excel file, the POJO class and the annotations on the POJO class attributes. There is no need to manually design the template file, so personalized Excel file output effects can be easily achieved, thereby improving development efficiency.
[0070] S104: Outputting an Excel file.
[0071] Specifically, after the Excel file is generated, the Excel file is output to a terminal device on the user side to complete the download of the Excel file.
[0072] In the embodiment of the present application, first, a download request for an Excel file is received; then, based on the download request, the POJO class corresponding to the download request and the annotations on the POJO class attributes are obtained; the POJO class is used to represent the data structure of the Excel file, and the annotations on the POJO class attributes are used to define the mapping relationship between the attributes and the column names of the Excel file; then, based on the POJO class and the annotations on the POJO class attributes, an Excel file is generated; finally, the Excel file is output. Thus, according to the pre-set POJO class and the annotations on the POJO class attributes, the mapping of the POJO object to the content in the Excel file is completed, and an Excel file is generated, thereby realizing the download of the Excel file. In the process of downloading the Excel file, there is no need to upload an empty template file first, and the download efficiency is high; according to different business needs and scenarios, the same POJO class can be used to change the annotations on the POJO class attributes to generate different Excel files, and the flexibility of downloading Excel files is high.
[0073] See also Figure 2 , this figure is an Excel file download flow chart provided in an embodiment of the present application, which shows the download process of an Excel file in a system architecture.
[0074] The user sends a download request for the Excel file to a company system consisting of one or more servers through a mobile terminal or a web page.
[0075] After receiving the download request for the Excel file, the company system can first perform data verification through the crop layer of the enterprise-level core system, for example, perform permission verification on the download request to ensure that only authorized users can download the requested Excel file.
[0076] After the data is verified by the crop layer, the business layer can obtain the POJO class and the annotations on the POJO class attributes corresponding to the download request based on the download request, and generate an Excel file based on the annotations on the POJO class and the POJO class attributes; then, the generated Excel file is passed to the file service in the form of a file stream, where the file stream is a continuous data transmission method that allows data to be transmitted without being saved to the hard disk.
[0077] The file service receives the file stream from the business layer, saves it as an actual Excel file, and then returns the file ID to the caller, where the caller can be a download request initiated by the user end or a part of the business layer.
[0078] If the caller is part of the business layer, the file service will first return the file ID to the business layer, and then the business layer will return the file ID to the user. The file ID is the file identifier (File ID), which can be used to track and access the generated Excel file. Users can download the generated Excel file from the company system through the file ID.
[0079] After the business layer receives the file ID, it can also return the file ID to the crop layer, and the crop layer will perform permission verification and / or data verification to ensure that the use of the file ID complies with the security policy and business rules of the existing layer, and then the crop layer will return the file ID to the user end.
[0080] See also Figure 3 , which is a flow chart of a method for uploading an Excel file provided in an embodiment of the present application, the method comprising:
[0081] S301: receiving an Excel file upload request.
[0082] Specifically, the Excel file upload request at least includes the Excel file to be uploaded.
[0083] S302: Based on the predefined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes, verify each row of data in the Excel file to be uploaded through the listener.
[0084] The annotations on the POJO class attributes at least need to define the mapping relationship between the attributes and the column names of the Excel file. In addition, the annotations can also include validation information such as data type validation, data range validation, and required item validation for subsequent data validation processes. For example, the annotations on the POJO class attributes can include that a certain attribute needs to be annotated as non-null (NotNull), or that a certain numeric attribute needs to be annotated as an integer within a specific range (Range).
[0085] In this embodiment, each row of data in the Excel file can be dynamically checked during the process of uploading the Excel file through a listener, such as the listening mechanism in EasyExcel. When the listener detects that a row of data does not meet the requirements of the predefined POJO class and its annotations, the upload of the row of data can be rejected and a corresponding error prompt can be given.
[0086] Therefore, we can verify the accuracy and completeness of the data before uploading it to the system, which can not only improve the efficiency of data processing, but also reduce the subsequent possible data errors and reduce the complexity of exception handling.
[0087] Optionally, if the data structure of the Excel file to be uploaded does not have a corresponding pre-defined POJO class, you can define a POJO class first; if the Excel file to be uploaded needs to add new fields or change the positions of existing fields compared to the existing data structure, you can modify the POJO class or the annotations on the POJO class attributes to expand and modify the POJO class to adapt to the Excel file to be uploaded; if there is a POJO class corresponding to the data structure of the Excel file to be uploaded, you can directly use the pre-defined POJO class.
[0088] S303: storing the Excel file to be uploaded based on the predefined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes.
[0089] Exemplarily, only the data verified in step S302 in the Excel file to be uploaded may be stored to complete uploading of the Excel file.
[0090] Optionally, when the Excel file upload request comes from the internal network, the Excel file to be uploaded is stored in the internal network disk array; when the Excel file upload request comes from the external network, the Excel file to be uploaded is stored in an external storage medium; then, the internal network disk array and the external storage medium back up data through a preset synchronization mechanism.
[0091] Therefore, the upload to the intranet is completed through the intranet disk array, and the upload to the extranet is completed through the external storage medium. The intranet disk array and the external storage medium back up the files after the Excel file is uploaded, so that all files only pass through the entry bandwidth once. There is no need to use the entry bandwidth for subsequent Excel file downloads. Both internal and external network users can enjoy high-speed upload and download services, which helps to improve user experience.
[0092] In an embodiment of the present application, the Excel file to be uploaded is stored based on the pre-defined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes. After the annotations on the POJO class and the POJO class attributes are defined, the same logic can be reused for data of the same structure. The code has high reusability, which can reduce code redundancy and improve development efficiency. When it is necessary to add new fields or change the position of existing fields, it is only necessary to modify the annotations on the POJO class or the POJO class attributes, and there is no need to modify the code for processing the template file. It is easy to expand and modify, thereby improving development efficiency.
[0093] See also Figure 4 , this figure is an Excel file upload flow chart provided in an embodiment of the present application, which shows the Excel file upload process in a system architecture.
[0094] The user sends an Excel file upload request to a company system composed of one or more servers through a mobile terminal or a web page, and the upload request includes the Excel file to be uploaded. When a user uploads an Excel file, a file ID for subsequent file processing can be obtained.
[0095] After the web layer in the company system receives the file ID uploaded by the user, it can transmit the file ID to the business layer.
[0096] The business layer can obtain the file stream associated with the file ID, and then use the monitoring mechanism of the Easyexcel library to verify the content of the Excel file; if the verification passes, the business layer converts the Excel row data into a Java object and transmits the converted data to the file service in the form of a data stream. The file service generates the final Excel file based on the received data stream and stores it.
[0097] See also Figure 5 , this figure is a schematic diagram of an Excel file downloading device provided in an embodiment of the present application, and the device includes: a first receiving module 501, an acquisition module 502, a generation module 503 and an output module 504.
[0098] The first receiving module 501 is used to receive a download request for an Excel file.
[0099] The acquisition module 502 is used to acquire the POJO class corresponding to the download request and the annotations on the POJO class attributes based on the download request; the POJO class is used to represent the data structure of the Excel file, and the annotations on the POJO class attributes are used to define the mapping relationship between the attributes and the column names of the Excel file.
[0100] The generation module 503 is used to generate an Excel file based on the POJO class and the annotations on the POJO class attributes.
[0101] The output module 504 is used to output an Excel file.
[0102] Therefore, according to the pre-set POJO class and the annotations on the POJO class attributes, the mapping of the POJO object to the content in the Excel file is completed, and the Excel file is generated, thereby realizing the download of the Excel file. In the process of downloading the Excel file, there is no need to upload an empty template file first, and the download efficiency is high; according to different business needs and scenarios, the same POJO class can be used to change the annotations on the POJO class attributes to generate different Excel files, and the flexibility of downloading Excel files is high.
[0103] Optionally, the download request includes format information of the Excel file; the format information of the Excel file includes at least one of table style, font style and cell format; the generation module 503 is specifically used to: generate the Excel file based on the format information of the Excel file, the POJO class and annotations on the POJO class attributes.
[0104] Optionally, the acquisition module 502 is specifically used for: when the download request comes from the internal network, based on the download request, acquiring the POJO class and annotations on the POJO class attributes corresponding to the download request from the internal network disk array; when the download request comes from the external network, based on the download request, acquiring the POJO class and annotations on the POJO class attributes corresponding to the download request from the external storage medium; the internal network disk array and the external storage medium back up data.
[0105] See also Figure 6 , this figure is a schematic diagram of an Excel file uploading device provided in an embodiment of the present application, and the device includes: a second receiving module 601 and a storage module 602.
[0106] The second receiving module 601 is used to receive an Excel file upload request; the Excel file upload request includes an Excel file to be uploaded.
[0107] The storage module 602 is used to store the Excel file to be uploaded based on the predefined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes.
[0108] Therefore, based on the pre-defined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes, the Excel file to be uploaded is stored. After the annotations on the POJO class and the POJO class attributes are defined, the same logic can be reused for data with the same structure. The code has high reusability, which can reduce code redundancy and improve development efficiency. When it is necessary to add new fields or change the position of existing fields, it is only necessary to modify the annotations on the POJO class or the POJO class attributes, without modifying the code for processing template files. It is easy to expand and modify, which improves development efficiency.
[0109] Optionally, the Excel file uploading device further comprises: a verification module, which is used to verify each row of data in the Excel file to be uploaded through a listener based on pre-defined POJO classes corresponding to the Excel file to be uploaded and annotations on POJO class attributes.
[0110] Optionally, the storage module 602 is specifically used for: when the Excel file upload request comes from the internal network, storing the Excel file to be uploaded in the internal network disk array; when the Excel file upload request comes from the external network, storing the Excel file to be uploaded in the external storage medium; the internal network disk array and the external storage medium perform data backup through a preset synchronization mechanism.
[0111] See also Figure 7 , this figure is a schematic diagram of an intranet and extranet data transmission system provided in an embodiment of the present application, the system includes: an external storage medium, an intranet disk array and a processor.
[0112] The external storage medium, the internal network disk array and the processor are communicatively connected; the external storage medium and the internal network disk array perform data mutual backup through a preset synchronization mechanism.
[0113] As an example, the external storage medium may be an external cloud storage, and the cloud storage service provided by the external storage medium may be an object storage system (OSS).
[0114] The external storage medium is used to store the external network data transmission program code and transmit the external network data transmission program code to the processor.
[0115] The intranet disk array is used to store the intranet data transmission program code and transmit the intranet data transmission program code to the processor.
[0116] The processor is used to execute the steps of the Excel file download method or the steps of the Excel file upload method according to the external network data transmission program code and the internal network data transmission program code.
[0117] Optionally, the external storage medium includes an external cloud storage and / or an external local storage.
[0118] Taking the external storage medium including both external cloud storage and external local storage as an example, if an Excel file upload request is received from an external network user through a terminal device, it can be determined whether the external network user has enabled the cloud storage function. If so, the Excel file to be uploaded is stored in the external cloud storage; if not, the Excel file to be uploaded is stored in the external local storage. If an Excel file download request is received from an external network user through a terminal device, it can be determined whether the external network user has enabled the cloud storage function. If so, it can be further determined whether the Excel file requested to be downloaded is stored in the cloud. If so, the POJO class corresponding to the download request and the annotations on the POJO class attributes are obtained from the external cloud storage; if the external network user has not enabled the cloud storage function, or the Excel file requested to be downloaded is not stored in the cloud, the POJO class corresponding to the download request and the annotations on the POJO class attributes can be obtained from the external local storage.
[0119] As a result, the external storage medium and the intranet disk array back up data with each other, and all files pass through the entry bandwidth only once. In the subsequent data transmission process, upload and download requests from the external network are completed through the external storage medium, and upload and download from the intranet are completed through the intranet disk array. There is no need to use the entry bandwidth for subsequent Excel file downloads. Both internal and external network users can enjoy high-speed upload and download services, which can improve user experience.
[0120] It should be noted that each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components indicated as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0121] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for downloading an Excel file, characterized in that: The method comprises: Receive the download request of Excel file; Based on the download request, a POJO class corresponding to the download request and annotations on the POJO class attributes are obtained; the POJO class is used to represent the data structure of the Excel file, and the annotations on the POJO class attributes are used to define a mapping relationship between the attributes and the column names of the Excel file; Generate an Excel file based on the POJO class and the annotations on the POJO class attributes; Output the Excel file.
2. The method according to claim 1, characterized in that: The download request includes format information of the Excel file; the format information of the Excel file includes at least one of a table style, a font style, and a cell format; The generating of the Excel file based on the annotations on the POJO class and the POJO class attributes includes: An Excel file is generated based on the format information of the Excel file, the POJO class and the annotations on the POJO class attributes.
3. The method according to claim 1, characterized in that: The obtaining, based on the download request, the POJO class corresponding to the download request and the annotations on the POJO class attributes includes: In the case where the download request comes from the internal network, based on the download request, obtaining the POJO class and annotations on the POJO class attributes corresponding to the download request from the internal network disk array; In the case where the download request comes from an external network, based on the download request, the POJO class and annotations on the POJO class attributes corresponding to the download request are obtained from an external storage medium; the intranet disk array and the external storage medium have data backup.
4. A method for uploading an Excel file, characterized in that: The method comprises: Receive an Excel file upload request; the Excel file upload request includes the Excel file to be uploaded; Based on the predefined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes, the Excel file to be uploaded is stored.
5. The method according to claim 4, characterized in that After reading the Excel file to be uploaded, the method further includes: Based on the predefined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes, each row of data in the Excel file to be uploaded is verified through a listener.
6. The method according to claim 4, characterized in that The storing of the Excel file to be uploaded comprises: When the Excel file upload request comes from the internal network, storing the Excel file to be uploaded in the internal network disk array; When the Excel file upload request comes from an external network, storing the Excel file to be uploaded in an external storage medium; The internal network disk array and the external storage medium perform data mutual backup via a preset synchronization mechanism.
7. A device for downloading Excel files, characterized in that: The device comprises: a first receiving module, an acquiring module, a generating module and an output module; The first receiving module is used to receive a download request for an Excel file; The acquisition module is used to acquire the POJO class corresponding to the download request and the annotations on the POJO class attributes based on the download request; the POJO class is used to represent the data structure of the Excel file, and the annotations on the POJO class attributes are used to define the mapping relationship between the attributes and the column names of the Excel file; The generating module is used to generate an Excel file based on the POJO class and the annotations on the POJO class attributes; The output module is used to output the Excel file.
8. An Excel file uploading device, characterized in that: The device comprises: a second receiving module and a storage module; The second receiving module is used to receive an Excel file upload request; the Excel file upload request includes an Excel file to be uploaded; The storage module is used to store the Excel file to be uploaded based on the predefined POJO class corresponding to the Excel file to be uploaded and the annotations on the POJO class attributes.
9. An intranet and extranet data transmission system, characterized in that: The system includes: an external storage medium, an intranet disk array and a processor; The external storage medium, the intranet disk array and the processor are in communication connection; the external storage medium and the intranet disk array perform data mutual backup through a preset synchronization mechanism; The external storage medium is used to store the external network data transmission program code and transmit the external network data transmission program code to the processor; The intranet disk array is used to store the intranet data transmission program code and transmit the intranet data transmission program code to the processor; The processor is used to execute the steps of the Excel file downloading method described in any one of claims 1 to 3, or execute the steps of the Excel file uploading method described in any one of claims 4 to 6 according to the external network data transmission program code and the internal network data transmission program code.
10. The system according to claim 9, characterized in that The external storage medium includes an external cloud storage and / or an external local storage.
