A method and apparatus for generating a spreadsheet
Patent Information
- Application Number
- CN202110629592.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-07
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2041-06-07
AI Technical Summary
[0005]然而,目前基于AutoPoi来实现的数据库中的数据导出,仅能针对一个表格进行导出,即数据导出时,仅能得到一个表格,无法针对多工作表和多表格进行导出,导致数据导出效率低,灵活性差
Smart Images

Figure CN113326682B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of financial technology (Fintech), and more particularly to a method and apparatus for generating spreadsheets. Background Technology
[0002] With the development of computer technology, more and more technologies (such as blockchain, cloud computing or big data) are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology, and big data technology is no exception. However, due to the security and real-time requirements of the financial and payment industries, higher requirements are also being placed on big data technology.
[0003] In existing technologies, exporting data from a database is generally achieved based on AutoPoi. For example, data tables in a database can be exported as files in different formats, such as Excel files (xlsx, xls) and Word files (doc, docx).
[0004] As is well known, any Excel file can contain multiple worksheets, and each worksheet can contain multiple tables. For example, worksheet 1 contains table a (containing students' math scores) and table b (containing students' Chinese scores).
[0005] However, the current data export functionality based on AutoPoi can only export data from a single table. This means that only one table can be exported at a time, and it cannot export data from multiple worksheets or tables, resulting in low efficiency and poor flexibility.
[0006] Therefore, a data export method is needed to enable data export from multiple worksheets and tables, thereby increasing the efficiency and flexibility of data export. Summary of the Invention
[0007] This invention provides a method and apparatus for generating spreadsheets.
[0008] In a first aspect, embodiments of the present invention provide a method for generating a spreadsheet, comprising:
[0009] The backend receives the table generation instructions sent by the frontend; the table generation instructions include each object to be exported.
[0010] The backend determines the export structure corresponding to each object to be exported in the database; the export structure records the worksheet attributes of the worksheet to which the object to be exported belongs and the table attributes of the object to be exported.
[0011] The backend generates a file stream containing each object to be exported according to the worksheet attributes and table attributes of the exported structure record, and sends it to the frontend so that the frontend can parse out a spreadsheet containing each object to be exported based on the file stream.
[0012] In the above technical solution, the export structure records the worksheet attributes of the worksheet to which the object to be exported belongs and the table attributes of the object to be exported. Based on the table attributes, data can be exported in units of tables. Based on the worksheet attributes, data can be exported in units of worksheets. This enables data export from multiple worksheets and tables, increasing the efficiency and flexibility of data export.
[0013] In existing technologies, the final file is generated by the backend and then sent to the frontend, resulting in no interaction between the frontend and the backend. In the technical solution of this invention, the backend sends the generated file stream to the frontend, and the frontend generates the file, thereby increasing the interaction capability between the frontend and the backend.
[0014] Optionally, the backend determines the export structure corresponding to each object to be exported in the database, including:
[0015] For any object to be exported, the backend determines the table attributes of the object to be exported based on the table attribute annotations of the object to be exported; and determines the worksheet to which the object to be exported belongs based on the worksheet annotations of the object to be exported.
[0016] For objects to be exported that belong to the same worksheet, the backend sorts the table attributes of the objects to be exported according to the table position annotations of the objects to be exported, and obtains the worksheet attributes.
[0017] The backend sorts the attributes of each worksheet according to the inter-table sorting annotation of the worksheet to which the object to be exported belongs, and obtains the export structure corresponding to each object to be exported.
[0018] In the above technical solution, worksheet attributes and table attributes are dynamically determined based on different annotations. Thus, when exporting data, the spreadsheet of the object to be exported is automatically determined according to the worksheet attributes and table attributes, which increases the efficiency and automation of data export.
[0019] Optionally, obtaining the exported structure corresponding to the object to be exported from the database also includes:
[0020] The object to be exported is used to generate the export structure according to a preset encapsulation data structure; the preset encapsulation data structure is obtained by modifying and encapsulating the underlying AutoPoi based on the object to be exported.
[0021] In the above technical solution, the exported structure can also be obtained based on the preset encapsulated data structure. This method can be implemented without relying on annotations, and data can be exported from multiple worksheets and tables based on the obtained exported structure, which increases the flexibility of determining the exported structure.
[0022] Optionally, the backend determines the export structure corresponding to each object to be exported in the database, and further includes:
[0023] The backend generates the export structure according to the preset encapsulation data structure for each object to be exported; the preset encapsulation data structure is obtained by modifying and encapsulating the underlying AutoPoi based on each object to be exported.
[0024] In the above technical solution, for any object to be exported, a table file stream is obtained according to AutoPoi, and then the table file streams in the same worksheet are sorted according to the table attributes to obtain a worksheet file stream. Finally, the generated file stream is generated according to the worksheet attributes, thereby realizing the export of data from multiple worksheets and tables.
[0025] Optionally, the backend generates a file stream including each object to be exported according to the worksheet attributes and table attributes of the exported structure record, including:
[0026] For objects to be exported belonging to the same worksheet, the backend generates a table file stream corresponding to the table attributes of the objects to be exported based on the table attributes of the objects to be exported, according to the AutoPoi method, and obtains a worksheet file stream;
[0027] The backend generates the file stream of the object to be exported by sorting the worksheet file streams according to the sorting of the worksheet attributes in the exported structure.
[0028] Optionally, generate a table file stream corresponding to the table attributes of the object to be exported, to obtain a worksheet file stream, including:
[0029] For any cell in the object to be exported, the backend determines the cell's position, format, and value in the table based on the cell's attribute value annotation;
[0030] The backend generates a table file stream corresponding to the table attributes of the object to be exported based on the position, format and value of each cell in the table;
[0031] The backend sorts the table file stream according to the table position annotation of the object to be exported, and obtains the worksheet file stream.
[0032] In the above technical solution, multiple table file streams in the same worksheet are obtained based on cell attribute value annotations. The multiple table file streams are then sorted to obtain a worksheet file stream, thereby enabling data export from multiple tables.
[0033] Optionally, the cell attribute values of the object to be exported may also include data dictionary annotations; the data dictionary annotations are used to match the cell attribute values with preset keys; the cell attribute values including data dictionary annotations are stored in a remote dictionary service;
[0034] Before the backend determines the position, format, and value of the cell in the table based on the cell attribute value annotation, it also includes:
[0035] The backend matches the cell to be exported in the remote dictionary service based on a preset key.
[0036] In the above technical solution, the cells to be exported are matched in the remote dictionary service without retrieving cell data from the database, thereby improving export efficiency. Furthermore, the cells can be matched according to preset keys to select the exported data, thereby increasing the flexibility of data export.
[0037] Secondly, embodiments of the present invention provide an apparatus for generating spreadsheets, comprising:
[0038] The acquisition module is used to acquire the table generation instructions sent by the front end; the table generation instructions include each object to be exported.
[0039] The processing module is used to determine the export structure corresponding to each object to be exported in the database; the export structure records the worksheet attributes of the worksheet to which the object to be exported belongs and the table attributes of the object to be exported.
[0040] The file stream containing each object to be exported is generated according to the worksheet attributes and table attributes of the exported structure record, and sent to the front end so that the front end can parse out a spreadsheet containing each object to be exported based on the file stream.
[0041] Optionally, the processing module is specifically used for:
[0042] For any object to be exported, determine the table attributes of the object based on its table attribute annotations; determine the worksheet to which the object belongs based on its worksheet annotations.
[0043] For objects to be exported that belong to the same worksheet, sort the table attributes of the objects to be exported according to the table position annotations of the objects to be exported to obtain the worksheet attributes;
[0044] Sort the attributes of each worksheet according to the inter-table sorting annotation of the worksheet to which the object to be exported belongs, and obtain the export structure corresponding to each object to be exported.
[0045] Optionally, the processing module is further configured to:
[0046] The export structure is generated by generating each object to be exported according to a preset encapsulation data structure; the preset encapsulation data structure is obtained by modifying and encapsulating the underlying AutoPoi based on the objects to be exported.
[0047] Optionally, the processing module is specifically used for:
[0048] For objects to be exported belonging to the same worksheet, based on the table attributes of the objects to be exported, a table file stream corresponding to the table attributes of the objects to be exported is generated according to the AutoPoi method, thus obtaining a worksheet file stream;
[0049] The file streams of each worksheet are sorted according to the attributes of each worksheet in the exported structure to generate the file stream of the object to be exported.
[0050] Optionally, the worksheet file stream includes a worksheet name, which is determined based on the worksheet identifier annotation of the first object to be exported in the worksheet.
[0051] Optionally, the processing module is specifically used for:
[0052] For any cell in the object to be exported, determine the cell's position, format, and value in the table based on the cell's attribute value annotation;
[0053] Generate a table file stream corresponding to the table attributes of the object to be exported based on the position, format, and value of each cell in the table;
[0054] The table file stream is sorted according to the table position annotations of the objects to be exported, resulting in a worksheet file stream.
[0055] Optionally, the cell attribute values of the object to be exported may also include data dictionary annotations; the data dictionary annotations are used to match the cell attribute values with preset keys; the cell attribute values including data dictionary annotations are stored in a remote dictionary service;
[0056] The processing module is also used for:
[0057] Before determining the position, format, and value of the cell in the table based on the cell attribute value annotation, the cell to be exported is matched in the remote dictionary service according to the preset key.
[0058] Thirdly, embodiments of the present invention also provide a computer device, comprising:
[0059] Memory, used to store program instructions;
[0060] The processor is used to call the program instructions stored in the memory and execute the spreadsheet generation method described above according to the obtained program.
[0061] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing computer-executable instructions for causing a computer to execute the above-described spreadsheet generation method. Attached Figure Description
[0062] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0063] Figure 1 This is a schematic diagram of an Excel file data format provided in an embodiment of the present invention;
[0064] Figure 2 A schematic diagram of a system architecture provided for an embodiment of the present invention;
[0065] Figure 3 A flowchart illustrating a method for generating a spreadsheet according to an embodiment of the present invention;
[0066] Figure 4 This is a schematic diagram of a method for verifying an object to be exported, provided by an embodiment of the present invention;
[0067] Figure 5 This is a schematic diagram of an annotation of an object to be exported, provided in an embodiment of the present invention;
[0068] Figure 6 This is a schematic diagram of a derived structure provided in an embodiment of the present invention;
[0069] Figure 7 This is a schematic diagram of the structure of a spreadsheet generation device provided in an embodiment of the present invention. Detailed Implementation
[0070] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0071] In existing technologies, databases contain multiple data tables containing important business data. Taking tax management as an example, a tax management database includes multiple types of taxes, such as value-added tax, corporate income tax, stamp duty, and other various taxes.
[0072] Each type of tax data is collected from various systems within the industry. For example, the general ledger data, expense control data, and manually set data of Company A are collected through the collection module. After obtaining the tax data, the data is exported as an Excel file for verification, calculation, and leadership review.
[0073] The data format of the Excel file is as follows: Figure 1 As shown, Figure 1 An exemplary diagram of an Excel file data format is shown, including multiple worksheets (Sheet1 and Sheet2, etc.), each worksheet may include multiple data tables (Table 1 and Table 2, etc.).
[0074] However, the current technical solution can only export data from one table at a time. That is, when exporting data, only one table can be obtained, which is equivalent to one Excel file. It is not possible to export data from multiple tables at the same time, nor can it generate multi-worksheet or multi-table spreadsheets, resulting in low data export efficiency and poor flexibility.
[0075] For example, the database includes a value-added tax (VAT) data table and a corporate income tax (CITax) data table. AutoPoi generates two separate Excel files, one for VAT data and the other for CITax. This demonstrates that current technology cannot export multiple tables of data into a single Excel file, nor can it export different tables of data into different worksheets within a single Excel file.
[0076] In existing technologies, the final file is generated by the backend and then sent to the frontend. This results in no interaction between the frontend and the backend. As a result, after the frontend issues a table generation command, it displays that the file export is successful, but in reality, the file export fails on the backend, causing the file received by the frontend to be in garbled form.
[0077] Therefore, a data export method is needed to enable data export from multiple worksheets and tables, thereby increasing the efficiency and flexibility of data export and enhancing the interaction capabilities between the front-end and back-end.
[0078] Figure 2 An exemplary system architecture applicable to an embodiment of the present invention is shown. The system architecture includes a server 200, which may include a processor 210, a communication interface 220, and a memory 230.
[0079] The communication interface 220 is used to obtain the object to be exported from the database, as well as the export structure corresponding to the object to be exported.
[0080] The processor 210 is the control center of the server 200, connecting various parts of the server 200 through various interfaces and routes. It performs various functions of the server 200 and processes data by running or executing software programs and / or modules stored in the memory 230, and by calling data stored in the memory 230. Optionally, the processor 210 may include one or more processing units.
[0081] The memory 230 can be used to store software programs and modules. The processor 210 executes various functional applications and data processing by running the software programs and modules stored in the memory 230. The memory 230 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function, etc.; the data storage area may store data created according to business processing, etc. In addition, the memory 230 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0082] It should be noted that the above Figure 2 The structure shown is merely an example, and the embodiments of the present invention are not limited thereto.
[0083] Based on the above description Figure 3 An exemplary flowchart of a spreadsheet generation method provided by an embodiment of the present invention is shown, which can be executed by a spreadsheet generation device.
[0084] like Figure 3 As shown, the process specifically includes:
[0085] Step 310: The backend receives the table generation instruction sent by the frontend.
[0086] In this embodiment of the invention, the table generation instruction is initiated by the front end and includes various objects to be exported. In other words, the table generation instruction includes multiple table data to be exported from the database.
[0087] Step 320: The backend determines the export structure corresponding to each object to be exported in the database.
[0088] In this embodiment of the invention, the export structure records the worksheet attributes of the worksheet to which the object to be exported belongs and the table attributes of the object to be exported.
[0089] Step 330: The backend generates a file stream including each object to be exported according to the worksheet attributes and table attributes of the exported structure record, and sends it to the frontend.
[0090] In this embodiment of the invention, after receiving the file stream, the front end parses the file stream to extract a spreadsheet containing each object to be exported. The back end sends the generated file stream to the front end, which then generates the file. The back end can also send the front end the steps in the file export process (the "exporting" step). The front end responds to the file stream sent by the back end after receiving it, indicating whether the export is successful or not, thereby increasing the interaction capability between the front end and the back end.
[0091] In step 320, before the backend determines the export structure corresponding to each object to be exported in the database, it can also verify the object to be exported to determine whether to export the object to be exported as a file stream.
[0092] In one feasible approach, the determination is based on a preset value for the object to be exported. For example, it is determined whether the object to be exported contains a preset allowed export value. If it does, the object to be exported is allowed to be exported as a file stream; otherwise, it is not allowed.
[0093] In another possible approach, the object to be exported is validated based on its worksheet or table properties. For example, it is determined whether the object to be exported includes worksheet or table properties. If it does, the object is allowed to be exported as a file stream; otherwise, it is not allowed.
[0094] In this embodiment of the invention, the object to be exported is validated based on worksheet attributes and table attributes, that is, based on the exported structure, such as... Figure 4 As shown, Figure 4 An exemplary schematic diagram of a method for verifying an object to be exported is shown. Specifically, after obtaining the object to be exported, it is determined whether the object to be exported includes an export structure and whether the export structure records the worksheet attributes and table attributes of the object to be exported. If so, the object to be exported is marked as an export object and is allowed to be exported as a file stream; otherwise, it is not allowed.
[0095] Furthermore, in one feasible approach, the exported structure of the object to be exported is obtained based on the annotations of the object to be exported.
[0096] Specifically, for any object to be exported, the backend determines the table attributes of the object based on the table attribute annotations of the object to be exported, and then determines the worksheet to which the object to be exported belongs based on the worksheet annotations of the object to be exported.
[0097] For objects to be exported that belong to the same worksheet, the backend sorts the table attributes of the objects to be exported according to the table position annotations of the objects to be exported, and then sorts the attributes of each worksheet according to the inter-table sorting annotations of the worksheet to which the objects to be exported belong, to obtain the export structure corresponding to the objects to be exported.
[0098] In this embodiment of the invention, the annotations for the worksheet of the object to be exported include worksheet annotations and inter-table sorting annotations. The annotations for the table of the object to be exported include table position annotations, worksheet identifier annotations, and table identifier annotations.
[0099] Figure 5 An example illustration shows a diagram of an annotation for an object to be exported, such as... Figure 5 As shown, the worksheet annotation is used to indicate the worksheet to which the object to be exported belongs, the inter-worksheet sorting annotation is used to indicate the sorting between worksheets, the intra-worksheet position annotation is used to indicate the sorting of the object to be exported within the worksheet, the worksheet identifier annotation is used to indicate the name of the worksheet to which the object to be exported applies, and the table identifier annotation is used to indicate the title of the object to be exported.
[0100] For example, the objects to be exported are grouped according to worksheet annotations, that is, the worksheets to which the objects to be exported belong are determined, the worksheets are sorted according to inter-sheet sorting annotations, the grouped objects to be exported are sorted according to intra-sheet position annotations, the worksheet name is determined according to worksheet identifier annotations, and the title of the objects to be exported is determined according to table identifier annotations.
[0101] To better describe the above technical solution, specific examples will be used to illustrate it below.
[0102] Example 1
[0103] The annotations for the three objects to be exported are as follows:
[0104] 1. @MultiExcel(group=”tms1”,orderSheetNum=1,orderGroupNum=1,title=”Passenger Transport Input Tax”,sheetName=”Manual Entry”);
[0105] Public class PaxtransTnputtax{};
[0106] 2. @MultiExcel(group=”tms1”,orderSheetNum=1,orderGroupNum=2,title=”Withholding and Paying Input Tax”,sheetName=”Manual Entry”);
[0107] Public class WithHoldInputTax{};
[0108] 3. @MultiExcel(group="tms2", orderSheetNum="2", orderGroupNum="1", title="Input Tax on Authentication Platform", sheetName="Download Authentication Platform");
[0109] Public class TmsCertifiedInputTax{};
[0110] Among them, "group" is the worksheet annotation, "orderSheetNum" is the inter-table sorting annotation, "orderGroupNum" is the intra-table position annotation, "sheetName" is the worksheet identifier annotation, and "title" is the table identifier annotation.
[0111] The objects to be exported include: “PaxtransTnputtax”, “WithHoldInputTax”, and “TmsCertifiedInputTax”. Since “PaxtransTnputtax” and “WithHoldInputTax” have the same worksheet annotation, both being “tms1”, they belong to the same worksheet. Based on the value of “orderSheetNum” being 1, the worksheet “tms1” is sorted as 1. Based on the value of “orderGroupNum”, the object to be exported, “PaxtransTnputtax”, is sorted as 1 in worksheet “tms1”, and the object to be exported, “WithHoldInputTax”, is sorted as 2 in worksheet “tms1”. Based on the “title”, the titles of the two are respectively determined as “Passenger Transport Input Tax” and “Withholding Input Tax”.
[0112] For the object to be exported, “TmsCertifiedInputTax”, the worksheet annotation is “tms2”. In the worksheet “tms2” to which “TmsCertifiedInputTax” belongs, the value of “orderSheetNum” is 2, so the sorting of worksheet “tms2” is determined to be 2. The value of “orderGroupNum” is determined to be 1, so the sorting of the object to be exported, “TmsCertifiedInputTax”, is determined to be 1 in worksheet “tms2”. And the title is determined to be “Input Tax of Certification Platform”.
[0113] Figure 6 An exemplary schematic diagram of a derived structure is shown, such as... Figure 6 As shown, the exported structure is a List. <list<map<String,Object> >>, where listA can correspond to worksheet "tms1", listB can correspond to worksheet "tms2", "PaxtransTnputtax" is mapA, "WithHoldInputTax" is mapB, and "TmsCertifiedInputTax" can correspond to mapC.
[0114] In another feasible approach, the export structure of the object to be exported is obtained based on a preset of the object to be exported.
[0115] Specifically, the object to be exported is generated into an export structure according to a preset encapsulated data structure. The preset encapsulated data structure is obtained by modifying and encapsulating the underlying AutoPoi based on the object to be exported.
[0116] Taking the above example as an example, the premise is as follows: the objects to be exported are "PaxtransTnputtax", "WithHoldInputTax", and "TmsCertifiedInputTax". The task to export the data is to place "PaxtransTnputtax" and "WithHoldInputTax" in the same worksheet "tms1" and sort the worksheet as 1, and place "TmsCertifiedInputTax" in another worksheet "tms2" and sort the worksheet as 2, and preset their respective titles and worksheet labels.
[0117] Programmers can modify AutoPoi at the underlying level to achieve the data export task mentioned above. Then, the modified AutoPoi can be encapsulated. Based on the encapsulated AutoPoi, the above-mentioned task can be achieved when exporting data from the object to be exported.
[0118] In step 330, the generation of file streams includes the generation of table file streams, the generation of worksheet file streams based on the above-mentioned export structure, and finally the generation of file streams for each object to be exported based on each worksheet file stream.
[0119] Specifically, for objects to be exported belonging to the same worksheet, the backend generates a table file stream corresponding to the table attributes of the objects to be exported based on the table attributes of the objects to be exported, according to the AutoPoi method, to obtain a worksheet file stream; and generates a file stream of the objects to be exported by sorting each worksheet file stream according to the order of the worksheet attributes in the export structure.
[0120] In this embodiment of the invention, for the export structure of each object to be exported, the total number of worksheets required and the specific tables within the worksheets can be determined, that is, by combining the above Example 1 and... Figure 6 This is equivalent to looping through the List of exported structures of each object to be exported. <list<map<String,Object> "list" in >> <map<String,Object> This determines the number of worksheets needed. Then, iterate through the List of export structures for each object to be exported. <list<map<String,Object> >> "map"<String,Object> "Identify the tables in the worksheet."
[0121] For any cell in a table, the cell includes an attribute value annotation in the AutoPoi mode to determine the cell's format, position, and value, thereby obtaining a table file stream for the table, and then obtaining a worksheet file stream based on the table file stream.
[0122] Furthermore, for any cell in the object to be exported, the backend determines the cell's position, format, and value in the table based on the cell attribute value annotation. Then, the backend generates a table file stream corresponding to the table attributes of the object to be exported based on the position, format, and value of each cell in the table. Finally, the table file stream is sorted according to the table position annotation of the object to be exported to obtain a worksheet file stream.
[0123] Taking the above example 1 as an example, the structure List is exported in a loop. <list<map<String,Object> The exported objects are identified as "PaxtransTnputtax", "WithHoldInputTax", and "TmsCertifiedInputTax", comprising two worksheets, "tms1" and "tms2". Worksheet "tms1" includes the exported objects "PaxtransTnputtax" and "WithHoldInputTax", specifically the tables "PaxtransTnputtax" and "WithHoldInputTax". Taking "PaxtransTnputtax" as an example, it contains ten cells with cell attribute annotations including name (column name), width (column width), height (column height), and type (export type), as shown in the following example annotation code:
[0124] @ExcelTarget("courseEntity");
[0125] public class CourseEntity implements java.io.Serializable{ / **primary key* / private String id;
[0126] / **Course Name* / ;
[0127] @Excel(name = "Course Name", orderNum = "1", needMerge = true);
[0128] private String name;
[0129] / **Teacher's primary key* / ;
[0130] The column name indicates the position of the cell in the table, the column width and column height indicate the format of the cell in the table, and the "Course Name" indicates the value of the cell in the table. This results in a table file stream for "PaxtransTnputtax". Then, the corresponding table file streams are sorted according to the in-table position annotation ("orderGroupNum") of each table ("PaxtransTnputtax" and "WithHoldInputTax") to obtain a worksheet file stream for worksheet "tms1".
[0131] Finally, after each worksheet ("tms1" and "tms2") has obtained its own table file stream, the worksheet file streams are sorted according to the inter-table sorting annotations to obtain the file stream.
[0132] The name of the worksheet file stream in the obtained file stream is determined based on the worksheet identifier annotation of the object to be exported. In one feasible approach, the worksheet identifier annotation of the last object to be exported in the worksheet is used as the name of that worksheet.
[0133] In this embodiment of the invention, the worksheet name is determined based on the worksheet identifier annotation of the first object to be exported in the worksheet.
[0134] Taking the above example 1 as an example, the worksheet "tms1" contains two objects to be exported ("PaxtransTnputtax" and "WithHoldInputTax"). Since "PaxtransTnputtax" is the first one in the worksheet "tms1", the value of the worksheet identifier annotation of "PaxtransTnputtax" is determined as the name of the worksheet "tms1", and the name of the worksheet "tms1" is "Manual Entry".
[0135] For example, based on AutoPoi annotations, in this embodiment of the invention, the cell attribute values of the object to be exported also include preset custom annotations to increase the flexibility of data export.
[0136] The cell attribute values of the object to be exported also include data dictionary annotations; the data dictionary annotations are used to match the cell attribute values with preset keys; the cell attribute values including data dictionary annotations are stored in a remote dictionary service;
[0137] Before the backend determines the cell's position, format, and value in the table based on the cell attribute value annotation, it matches the cell to be exported in the remote dictionary service according to a preset key.
[0138] Taking Example 1 above as an example, the data in each cell of the "PaxtransTnputtax" table can be divided into data from Monday to Sunday, and also into data based on gender (male and female). Monday to Sunday and gender (male and female) are the preset keys. When determining the file stream, if the preset key is selected as "male", the resulting table file stream will only include data in the "PaxtransTnputtax" table whose cell attribute value is annotated as "male". The characteristic of a data dictionary is its one-to-one data association. To increase the flexibility of exported data, multiple selection keys for delimiters can be used.
[0139] For example, when determining the table file stream, if the preset keys are "Monday" and "Tuesday", the table file stream will only include data from the "PaxtransTnputtax" table whose cell attribute values are annotated as "Monday" and "Tuesday". Similarly, when the preset keys are "Tuesday", "Wednesday", and "Friday", the table file stream will only include data from the "PaxtransTnputtax" table whose cell attribute values are annotated as "Tuesday", "Wednesday", and "Friday". Further examples will not be provided here.
[0140] For example, the cell attribute value may also include a permission annotation, which is used by the database to determine whether the export requester has export permissions.
[0141] Taking the above example 1 as an example, regarding permission annotations, suppose "PaxtransTnputtax" is the data owned by Zhang, "WithHoldInputTax" is the data owned by Li, and "TmsCertifiedInputTax" is the data owned by Wang. The permission annotations now include a one-to-one correspondence between the requester and the data owner. That is, when the requester of the three data to be exported is Zhang, only the table file stream of "PaxtransTnputtax" can be obtained.
[0142] Based on the same technological concept Figure 7 An exemplary schematic diagram of a spreadsheet generation apparatus provided in an embodiment of the present invention is shown, illustrating the process that the apparatus can execute.
[0143] like Figure 7 As shown, the device specifically includes:
[0144] The acquisition module 710 is used to acquire the table generation instructions sent by the front end; the table generation instructions include each object to be exported.
[0145] Processing module 720 is used to determine the export structure corresponding to each object to be exported in the database; the export structure records the worksheet attributes of the worksheet to which the object to be exported belongs and the table attributes of the object to be exported.
[0146] The file stream containing each object to be exported is generated according to the worksheet attributes and table attributes of the exported structure record, and sent to the front end so that the front end can parse out a spreadsheet containing each object to be exported based on the file stream.
[0147] Optionally, the processing module 720 is specifically used for:
[0148] For any object to be exported, determine the table attributes of the object based on its table attribute annotations; determine the worksheet to which the object belongs based on its worksheet annotations.
[0149] For objects to be exported that belong to the same worksheet, sort the table attributes of the objects to be exported according to the table position annotations of the objects to be exported to obtain the worksheet attributes;
[0150] Sort the attributes of each worksheet according to the inter-table sorting annotation of the worksheet to which the object to be exported belongs, and obtain the export structure corresponding to each object to be exported.
[0151] Optionally, the processing module 720 is further configured to:
[0152] The export structure is generated by generating each object to be exported according to a preset encapsulation data structure; the preset encapsulation data structure is obtained by modifying and encapsulating the underlying AutoPoi based on the objects to be exported.
[0153] Optionally, the processing module 720 is specifically used for:
[0154] For objects to be exported belonging to the same worksheet, based on the table attributes of the objects to be exported, a table file stream corresponding to the table attributes of the objects to be exported is generated according to the AutoPoi method, thus obtaining a worksheet file stream;
[0155] The file streams of each worksheet are sorted according to the attributes of each worksheet in the exported structure to generate the file stream of the object to be exported.
[0156] Optionally, the worksheet file stream includes a worksheet name, which is determined based on the worksheet identifier annotation of the first object to be exported in the worksheet.
[0157] Optionally, the processing module 720 is specifically used for:
[0158] For any cell in the object to be exported, determine the cell's position, format, and value in the table based on the cell's attribute value annotation;
[0159] Generate a table file stream corresponding to the table attributes of the object to be exported based on the position, format, and value of each cell in the table;
[0160] The table file stream is sorted according to the table position annotations of the objects to be exported, resulting in a worksheet file stream.
[0161] Optionally, the cell attribute values of the object to be exported may also include data dictionary annotations; the data dictionary annotations are used to match the cell attribute values with preset keys; the cell attribute values including data dictionary annotations are stored in a remote dictionary service;
[0162] The processing module 720 is further configured to:
[0163] Before determining the position, format, and value of the cell in the table based on the cell attribute value annotation, the cell to be exported is matched in the remote dictionary service according to the preset key.
[0164] Based on the same technical concept, embodiments of the present invention also provide a computer device, including:
[0165] Memory, used to store program instructions;
[0166] The processor is used to call the program instructions stored in the memory and execute the spreadsheet generation method described above according to the obtained program.
[0167] Based on the same technical concept, embodiments of the present invention also provide a computer-readable storage medium storing computer-executable instructions for causing a computer to execute the above-described spreadsheet generation method.
[0168] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0169] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0170] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0171] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0172] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for generating a spreadsheet, characterized in that, include: The backend receives the table generation instructions sent by the frontend; the table generation instructions include each object to be exported. The backend determines the export structure corresponding to each object to be exported in the database; The exported structure records the worksheet attributes of the worksheet to which the object to be exported belongs and the table attributes of the object to be exported. The worksheet attributes are used to characterize the worksheet division of each object to be exported in the spreadsheet and the order between the worksheets. For objects to be exported belonging to the same worksheet, the backend determines the position, format, and value of the cell in the table based on the table attributes of the objects to be exported and according to the AutoPoi method, for any cell in the objects to be exported, the backend determines the position, format, and value of the cell in the table based on the cell attribute value annotation; The backend generates a table file stream corresponding to the table attributes of the object to be exported based on the position, format, and value of each cell in the table; the backend sorts the table file stream according to the table position annotation of the object to be exported to obtain a worksheet file stream. The backend generates the file stream of the object to be exported by sorting the worksheet file streams according to the sorting of the worksheet attributes in the exported structure. The backend sends the file stream to the frontend, so that the frontend can parse the file stream to generate a spreadsheet that includes multiple worksheets, and at least one worksheet includes multiple tables.
2. The method as described in claim 1, characterized in that, The backend determines the export structure corresponding to each object to be exported in the database, including: For any object to be exported, the backend determines the table attributes of the object to be exported based on the table attribute annotations of the object to be exported; and determines the worksheet to which the object to be exported belongs based on the worksheet annotations of the object to be exported. For objects to be exported that belong to the same worksheet, the backend sorts the table attributes of the objects to be exported according to the table position annotations of the objects to be exported, and obtains the worksheet attributes. The backend sorts the attributes of each worksheet according to the inter-table sorting annotation of the worksheet to which the object to be exported belongs, and obtains the export structure corresponding to each object to be exported.
3. The method as described in claim 1, characterized in that, The backend determines the export structure corresponding to each object to be exported in the database, and also includes: The backend generates the export structure according to the preset encapsulation data structure for each object to be exported; the preset encapsulation data structure is obtained by modifying and encapsulating the underlying AutoPoi based on each object to be exported.
4. The method as described in claim 1, characterized in that, The worksheet file stream includes worksheet names, which are determined based on the worksheet identifier annotation of the first object to be exported in the worksheet.
5. The method as described in claim 1, characterized in that, The cell attribute values of the object to be exported also include data dictionary annotations; the data dictionary annotations are used to match the cell attribute values with preset keys; the cell attribute values including data dictionary annotations are stored in a remote dictionary service; Before the backend determines the position, format, and value of the cell in the table based on the cell attribute value annotation, it also includes: The backend matches the cell to be exported in the remote dictionary service based on a preset key.
6. A spreadsheet generation device, characterized in that, include: The acquisition module is used to acquire the table generation instructions sent by the front end, wherein the table generation instructions include each object to be exported; Determine the export structure corresponding to each object to be exported in the database; The exported structure records the worksheet attributes of the worksheet to which the object to be exported belongs and the table attributes of the object to be exported. The worksheet attributes are used to characterize the worksheet division of each object to be exported in the spreadsheet and the order between the worksheets. The processing module is used to determine the position, format and value of any cell in the table for any object to be exported from the same worksheet, based on the table attributes of the object to be exported and according to the AutoPoi method. The backend generates a table file stream corresponding to the table attributes of the object to be exported based on the position, format, and value of each cell in the table; the backend sorts the table file stream according to the table position annotation of the object to be exported to obtain a worksheet file stream. The backend generates the file stream of the object to be exported by sorting the worksheet file streams according to the sorting of the worksheet attributes in the exported structure. The backend sends the file stream to the frontend, so that the frontend can parse the file stream to generate a spreadsheet that includes multiple worksheets, and at least one worksheet includes multiple tables.
7. A computer device, characterized in that, include: Memory, used to store program instructions; A processor is configured to invoke program instructions stored in the memory and execute the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to perform the method according to any one of claims 1 to 5.