A data processing method, apparatus, electronic device, and storage medium

By reading and traversing the last row of sub-table data in vertically merged cells of a spreadsheet, the structural relationship between adjacent columns is determined, and a tree-structured data is generated. This solves the problems of low efficiency and low accuracy in existing technologies, and achieves efficient and accurate data restoration.

CN117634432BActive Publication Date: 2026-05-26RICHFIT INFORMATION TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
RICHFIT INFORMATION TECH
Filing Date
2022-08-16
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing technologies are inefficient and inaccurate when restoring vertically merged cell data in a spreadsheet into a tree structure, especially when there are multiple vertically merged cells, which can easily lead to errors in the tree structure.

Method used

By reading the last row of sub-table data in each vertically merged cell, determining that other rows are empty, and obtaining table data from multiple adjacent columns, traversing their structural relationships, a tree-structured data is generated.

Benefits of technology

This reduces the number of loops, improves restoration efficiency, and ensures the accuracy and consistency of tree-structured data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117634432B_ABST
    Figure CN117634432B_ABST
Patent Text Reader

Abstract

This application provides a data processing method, apparatus, electronic device, and storage medium. The method includes: firstly, reading the table data of each sub-table in a spreadsheet; then, traversing the table data of each group of adjacent columns to determine the structural relationship between multiple groups of adjacent columns; and finally, generating tree structure data corresponding to at least one vertically merged cell based on the table data and the structural relationship between multiple groups of adjacent columns. This application can efficiently restore the tree structure corresponding to vertically merged cells in a spreadsheet.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a data processing method, apparatus, electronic device and storage medium. Background Technology

[0002] A spreadsheet, also known as an electronic data sheet, is a type of computer program that simulates a paper-based calculation table. It displays a grid of rows and columns. Cells can contain numerical values, calculations, or text.

[0003] When importing data from a spreadsheet into a database, if the spreadsheet does not contain merged cells, the result can be obtained by reading the value and position information of each sub-cell, and then imported into the database. However, when the spreadsheet contains vertically merged cells, the data in the vertically merged cells corresponds to a tree structure. To store the data in the vertically merged cells into the database, the data in the vertically merged cells in the spreadsheet needs to be restored to a tree structure as the result before importing the result into the database.

[0004] The current method for restoring vertically merged cell data in a spreadsheet into a tree structure involves filling empty fields. However, this method requires multiple loops, resulting in low restoration efficiency. Furthermore, when restoring a tree structure based on the values ​​under all fields, it also leads to low restoration accuracy. Summary of the Invention

[0005] In view of this, embodiments of this application provide a data processing method, apparatus, electronic device, and storage medium that can reduce the number of loops and efficiently restore the tree structure corresponding to vertically merged cells in a spreadsheet.

[0006] The technical solution of this application embodiment is implemented as follows:

[0007] In a first aspect, embodiments of this application provide a data processing method, including the following steps:

[0008] For a spreadsheet that includes at least one vertically merged cell, the table data of each sub-table in the spreadsheet is read; wherein, the table data of the last row of the sub-table of each vertically merged cell is determined according to the target data of the vertically merged cell, and the table data of the other rows of the sub-table of each vertically merged cell are empty;

[0009] Obtain table data from multiple sets of adjacent columns, traverse the table data from each set of adjacent columns respectively, and determine the structural relationship between the multiple sets of adjacent columns of table data; wherein, the structural relationship includes the parallel relationship and the subordinate relationship between the table data;

[0010] Based on the table data and the structural relationships between the multiple sets of adjacent table data, a tree structure data corresponding to the at least one vertically merged cell is generated.

[0011] In one possible implementation, reading the table data of each sub-table in the spreadsheet includes:

[0012] Construct a list set whose row and column lengths correspond to the row and column lengths of the spreadsheet;

[0013] Read the table data of each sub-table in the spreadsheet, and each sub-table corresponds to a reading result;

[0014] The read results are placed into the list set, wherein the row and column positions of each read result in the list set correspond to the row and column positions of the data in each cell of the spreadsheet.

[0015] In one possible implementation, each group of adjacent columns includes a first adjacent column and a second adjacent column; the step of traversing the table data of each group of adjacent columns to determine the structural relationship between the multiple groups of adjacent column table data includes:

[0016] The table data of the first adjacent column and the second adjacent column are traversed respectively. Based on the table data of the first adjacent column, at least one first independent cell in the first adjacent column is determined, and based on the table data of the second adjacent column, at least one second independent cell in the second adjacent column is determined.

[0017] Determine the first row number of the at least one first independent cell, and the second row number of the at least one second independent cell;

[0018] The parallel relationship between the first independent cells is determined based on the number of at least one first row, and the parallel relationship between the at least one second independent cells is determined based on the number of at least one second row; and the subordinate relationship between at least one first independent cell and at least one second independent cell is determined based on the number of at least one first row and the number of at least one second row.

[0019] In one possible implementation, the first adjacent column includes a first independent cell, and the second adjacent column includes at least one second independent cell, wherein the first independent cell and the at least one second independent cell are subordinate to each other, and each second independent cell is parallel to the other; or, the first adjacent column includes at least one first independent cell, and the second adjacent column includes at least one second independent cell, wherein each first independent cell and the at least one second independent cell are subordinate to each other, and each first independent cell is parallel to the other, and each second independent cell is parallel to the other.

[0020] In one possible implementation, the step of traversing the table data of the first adjacent column and the second adjacent column respectively, determining at least one first independent cell in the first adjacent column based on the table data of the first adjacent column, and determining at least one second independent cell in the second adjacent column based on the table data of the second adjacent column, includes:

[0021] Perform the following operations on the first adjacent column and the second adjacent column respectively:

[0022] Record the row number of the table data in the first row of the current column as the starting row number, and iterate through the table data in the current column. When the table data is not empty, record the row number of the non-empty table data as the ending row number, and update the starting row number to the row number of the next row of the non-empty table data.

[0023] The sub-table corresponding to the starting row number, the sub-table corresponding to the ending row number, and all sub-tables between the starting row number and the ending row number are treated as a single cell, wherein the single cell includes a first single cell or a second single cell.

[0024] Determine the row number of at least one independent cell, including:

[0025] All rows from the start row number to the end row number are counted as the row number of at least one independent cell.

[0026] In one possible implementation, generating the tree structure data corresponding to the at least one vertically merged cell based on the table data and the structural relationships between the multiple sets of adjacent table data includes:

[0027] Construct at least one first set and at least one second set, wherein each first set is used to store a first independent cell and each second set is used to store a second independent cell;

[0028] Place each first independent cell into its corresponding first set, and place each second independent cell into its corresponding second set;

[0029] The second set corresponding to the second independent cell with a subordinate relationship is determined as a subset of the first set corresponding to the first independent cell, and the first set corresponding to the first independent cell with a parallel relationship is determined as a parallel first set, and the second set corresponding to the second independent cell with a parallel relationship is determined as a parallel second set.

[0030] In one possible implementation, the method further includes:

[0031] The tree structure data is stored in a database, or a tree diagram corresponding to the tree structure data is generated based on the tree structure data.

[0032] Secondly, embodiments of this application also provide a data processing apparatus, the apparatus comprising:

[0033] The reading module is used to read the table data of each sub-table in a spreadsheet that includes at least one vertically merged cell; wherein the table data of the last row of the sub-table in each vertically merged cell is determined according to the target data of the vertically merged cell, and the table data of the other rows of the sub-table in each vertically merged cell are empty.

[0034] The processing module is used to acquire table data of multiple sets of adjacent columns, traverse the table data of each set of adjacent columns, and determine the structural relationship between the multiple sets of adjacent columns of table data; wherein, the structural relationship includes the parallel relationship and the subordinate relationship between the table data;

[0035] The generation module is used to generate tree structure data corresponding to the at least one vertically merged cell based on the table data and the structural relationship between the multiple sets of adjacent table data.

[0036] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the data processing method described in any of the first aspects.

[0037] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the data processing method described in any one of the first aspects.

[0038] The embodiments of this application have the following beneficial effects:

[0039] By reading the table data of each sub-table in a spreadsheet including vertically merged cells, and traversing the table data of each group of adjacent columns in the reading results, since the target data of the vertically merged cells is only read in the last row of the sub-table, and the table data of the other rows of the sub-tables are empty, the number of vertically merged cells in each column of each group of adjacent columns and the number of rows of each vertically merged cell can be determined. Based on this, the structural relationship between each group of adjacent column data can be determined by the correspondence between the row numbers. Since only one traversal of the reading results is needed to obtain the structural relationship between each group of adjacent column data, compared with the multiple traversals of the traditional method, the number of loops can be reduced, thus efficiently obtaining the tree structure data corresponding to at least one vertically merged cell. Attached Figure Description

[0040] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0041] Figure 1 This is a flowchart illustrating steps S101-S103 provided in the embodiments of this application;

[0042] Figure 2 This is a flowchart illustrating steps S201-S203 provided in the embodiments of this application;

[0043] Figure 3 This is a flowchart illustrating steps S301-S303 provided in the embodiments of this application;

[0044] Figure 4 This is a flowchart illustrating steps S401-S403 provided in the embodiments of this application;

[0045] Figure 5 This is a schematic diagram of the structure of the data processing apparatus provided in the embodiments of this application;

[0046] Figure 6 This is a schematic diagram of the composition structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.

[0048] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0049] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0050] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0051] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.

[0052] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application and is not intended to limit the scope of this application.

[0053] During the implementation of the embodiments of this application, the applicant discovered the following problems with the related technology:

[0054] In related technologies, the read sub-table content is looped through. When a null field appears, the first null field with a value in the same column following the null field is filled into the null field. Based on the above method, each null field is filled, and each filling requires a traversal, resulting in low restoration efficiency. When restoring tree structure data, fields with the same data are used as a common parent node for tree splicing. However, if there is at least one tree structure in the spreadsheet, its root node is two, that is, there are two vertically merged cells in the first column, and the target data of the two vertically merged cells is the same. This will cause the two vertically merged cells to be treated as a single vertically merged cell (with the same value after filling) when restoring the tree structure data, thus becoming a root node, resulting in an incorrect tree structure.

[0055] See Figure 1 , Figure 1 This is a flowchart illustrating steps S101-S103 of the data processing method provided in this application embodiment, which will be combined with... Figure 1 Steps S101-S103 shown will be explained.

[0056] Step S101: For a spreadsheet that includes at least one vertically merged cell, read the table data of each sub-table in the spreadsheet; wherein, the table data of the last row of the sub-table in each vertically merged cell is determined according to the target data of the vertically merged cell, and the table data of the other rows of the sub-table in each vertically merged cell are empty.

[0057] Step S102: Obtain table data of multiple sets of adjacent columns, traverse the table data of each set of adjacent columns respectively, and determine the structural relationship between the multiple sets of adjacent columns of table data; wherein, the structural relationship includes the parallel relationship and the subordinate relationship between the table data;

[0058] Step S103: Based on the table data and the structural relationship between the multiple sets of adjacent table data, generate tree structure data corresponding to the at least one vertically merged cell.

[0059] The above data processing method reads the table data of each sub-table in a spreadsheet including vertically merged cells, and iterates through the table data of each group of adjacent columns in the read results. Since the target data is only read in the last row of the vertically merged cells, and the table data of other rows of the sub-tables are empty, the number of vertically merged cells in each column of each group of adjacent columns and the number of rows of each vertically merged cell can be determined. Based on this, the structural relationship between each group of adjacent columns can be determined by the correspondence between the number of rows. Since only one traversal of the read results is needed to obtain the structural relationship between each group of adjacent columns, compared with the multiple traversals of the traditional method, the number of loops can be reduced, thus efficiently obtaining the tree structure data corresponding to at least one vertically merged cell.

[0060] The exemplary steps described above in the embodiments of this application will be explained below.

[0061] In step S101, for a spreadsheet including at least one vertically merged cell, the table data of each sub-table in the spreadsheet is read; wherein, the table data of the last row of the sub-table of each vertically merged cell is determined according to the target data of the vertically merged cell, and the table data of the other rows of the sub-table of each vertically merged cell are empty.

[0062] In some embodiments, a spreadsheet typically refers to an Excel spreadsheet, but it can also be a WPS spreadsheet. There is no limitation on the type of spreadsheet here. When reading data from an Excel spreadsheet, the table data of each sub-table in the spreadsheet can be read through the I / O interface in the Java core library.

[0063] As an example, refer to Table 1. The first column of Table 1 is a vertically merged cell with 10 rows, and the target data is "Indicator 1"; the second column is a vertically merged cell with 4 rows (target data is "Indicator 1-1") and a vertically merged cell with 6 rows (target data is "Indicator 1-2"); the third column is a vertically merged cell with 2 rows (target data is "Indicator 1-1-1"), a vertically merged cell with 2 rows (target data is "Indicator 1-1-2"), a sub-table with 1 row (target data is "Indicator 1-2-1"), a vertically merged cell with 2 rows (target data is "Indicator 1-2-2"), and a vertically merged cell with 3 rows (target data is "Indicator 1-2-3"); the fourth column is 10 "1"s. The target data for each sub-table in Table 1 is sequentially "Indicator 1-1-1-1", "Indicator 1-1-1-2", "Indicator 1-1-2-1", "Indicator 1-1-2-2", "Indicator 1-2-1-1", "Indicator 1-2-2-1", "Indicator 1-2-2-2", "Indicator 1-2-3-1", "Indicator 1-2-3-2", and "Indicator 1-2-3-3". The table data in each sub-table in Table 1 is then read through the I / O interface. Since the table data in the last row of the vertically merged cell is determined based on the target data of that vertically merged cell, the table data in other rows of the sub-tables will be null after reading. The results are shown in Table 2, where "null" represents a null value.

[0064] Table 1

[0065]

[0066] Table 2

[0067] null null null Indicator 1-1-1-1 null null Indicator 1-1-1 Indicator 1-1-1-2 null null null Indicator 1-1-2-1 null Indicator 1-1 Indicator 1-1-2 Indicator 1-1-2-2 null null Indicator 1-2-1 Indicator 1-2-1-1 null null null Indicator 1-2-2-1 null null Indicator 1-2-2 Indicator 1-2-2-2 null null null Indicator 1-2-3-1 null null null Indicator 1-2-3-2 Indicator 1 Indicator 1-2 Indicator 1-2-3 Indicator 1-2-3-3

[0068] The above method reads the table data of each sub-table in the spreadsheet, providing a data foundation for subsequent processing of the table data.

[0069] In step S102, multiple sets of adjacent column table data are obtained, and the table data of each set of adjacent columns is traversed to determine the structural relationship between the multiple sets of adjacent column table data; wherein, the structural relationship includes the parallel relationship and the subordinate relationship between the table data.

[0070] In some embodiments, in order to determine the tree structure corresponding to the data in the spreadsheet, it is necessary to traverse the adjacent columns in the read data to obtain the structural relationship between the table data of the adjacent columns. In this embodiment, the adjacent columns can be any two adjacent columns of data, such as the first and second columns of data, the third and fourth columns of data, or the second and third columns of data.

[0071] As an example, referring to Table 2, traversing the first and second columns reveals that there is one vertically merged cell in the first column and two vertically merged cells in the second column. The row number of the two vertically merged cells in the second column matches the row number of the vertically merged cells in the first column. Further, we can determine the subordinate relationship between the table data of the two vertically merged cells in the second column and the vertically merged cells in the first column. Moreover, the two vertically merged cells in the second column, which belong to the same column, are parallel, meaning that the vertically merged cell in the first column is the root node of the two vertically merged cells in the second column, and the two vertically merged cells in the second column are two parallel child nodes at the same level.

[0072] The above method establishes the structural relationships between adjacent column data, providing a structural basis for obtaining tree-structured data corresponding to the spreadsheet.

[0073] In step S103, based on the table data and the structural relationship between the multiple sets of adjacent table data, a tree structure data corresponding to the at least one vertically merged cell is generated.

[0074] Here, the tree structure in the spreadsheet can be restored based on the structural relationship between each group of adjacent column data and the table data, generating at least one tree structure data corresponding to a vertically merged cell. For example, if the first column in Table 2 contains only one vertically merged cell, then a tree is generated. If the first column contains multiple vertically merged cells, then each vertically merged cell represents the root node of a tree, and multiple trees are generated accordingly.

[0075] The above method generates at least one tree structure data corresponding to vertically merged cells, providing a data foundation for importing tabular data from spreadsheets into a database and storing it as a tree structure.

[0076] In some embodiments, see Figure 2 , Figure 2 This is a flowchart illustrating steps S201-S203 provided in the embodiments of this application. Figure 1 The step S101 shown can be implemented through steps S201-S203, which will be explained in conjunction with each step.

[0077] In step S201, a list set with row and column lengths corresponding to the row and column lengths of the spreadsheet is constructed.

[0078] Here, in order to ensure that the table data of each sub-table after reading is consistent with the row and column positions in the spreadsheet, it is necessary to first create a list collection to store the table data of each sub-table. The row and column length of the list collection corresponds to the row and column length of the spreadsheet.

[0079] In step S202, the table data of each sub-table in the spreadsheet is read, and each sub-table corresponds to a reading result.

[0080] In step S203, the reading results are placed into the list set, wherein the row and column positions of each reading result in the list set correspond to the row and column positions of each cell of data in the spreadsheet.

[0081] Here, the table data of each sub-table in the spreadsheet is read, and the reading results are sequentially placed into the corresponding positions in the list collection, thereby constructing the reading results corresponding to the row and column positions of the spreadsheet, providing a processing basis for subsequent processing of the table data.

[0082] In some embodiments, see Figure 3 , Figure 3 This is a flowchart illustrating steps S301-S303 provided in the embodiments of this application. Figure 1 The step S102 shown can be implemented through steps S301-S303, which will be explained in conjunction with each step.

[0083] In step S301, the table data of the first adjacent column and the second adjacent column are traversed respectively. Based on the table data of the first adjacent column, at least one first independent cell in the first adjacent column is determined, and based on the table data of the second adjacent column, at least one second independent cell in the second adjacent column is determined.

[0084] In some embodiments, the first and second adjacent columns of each group of adjacent columns are traversed respectively. Since the reading result of a vertically merged cell except for the last row is empty, the number of vertically merged cells in the first or second adjacent column can be known during the traversal. Furthermore, since there may be a situation where vertically merged cells and non-merged cells (sub-tables) coexist in a certain adjacent column, in this case, the vertically merged cells and sub-tables in that column are considered to be parallel. In the first adjacent column, a first independent cell is defined to represent the vertically merged cells or non-merged cells of the current column, and in the second adjacent column, a second independent cell is defined to represent the vertically merged cells or non-merged cells of the current column.

[0085] It should be noted that, in the embodiments of this application, an independent cell is either a complete merged cell or a sub-table that has not been merged, and each independent cell is not empty.

[0086] As an example, refer to Table 2. Traverse the first and second columns of Table 2. The first column in Table 2 is the first adjacent column, and the second column in Table 2 is the second adjacent column. When traversing the first adjacent column, since rows 0-8 (starting row number 0) are all empty values, and only row 9 has a non-empty value, rows 0-9 in the first adjacent column can be identified as a first independent cell. For the second adjacent column, rows 0-3 are empty values, and row 4 has a non-empty value, so rows 0-4 can be identified as a second independent cell. Continuing to traverse downwards, rows 5-8 are empty values, and row 9 has a non-empty value, so rows 5-9 are also a second independent cell.

[0087] The above method iterates through the table data in adjacent columns, obtaining the independent cells in each adjacent column, which provides a basis for determining the structural relationship between the independent cells.

[0088] In step S302, the first row number of the at least one first independent cell and the second row number of the at least one second independent cell are determined.

[0089] Here, after determining the first independent cell and the second independent cell, it is also necessary to determine the number of rows in the first independent cell and the second independent cell. The first row of the first independent cell is numbered 0-9, and the second rows of the two second independent cells are numbered 0-3 and 4-9 respectively.

[0090] In step S303, the parallel relationship between the first independent cells is determined based on the number of at least one first row, and the parallel relationship between the at least one second independent cells is determined based on the number of at least one second row; and the subordinate relationship between at least one first independent cell and at least one second independent cell is determined based on the number of at least one first row and the number of at least one second row.

[0091] As an example, in Table 2, there is only one first independent cell in the first adjacent column. Therefore, there are no first independent cells with a parallel relationship in the first adjacent column. In the second adjacent column, there are two second independent cells, one in rows 0-3 and one in rows 4-9. Therefore, the second independent cells formed by rows 0-3 and the second independent cells formed by rows 4-9 are parallel. The number of rows of the first independent cell is 0-9, which corresponds to the second independent cells in rows 0-3 and 4-9. Therefore, it can be further confirmed that the two second independent cells in the second adjacent column belong to the first independent cells in the first adjacent column.

[0092] The above method determines the parallel relationship between the first independent cells in adjacent columns, the parallel relationship between the second independent cells, and the subordinate relationship between the first independent cells and the second independent cells, providing a structural foundation for the construction of the tree structure.

[0093] It should be noted that steps S301-S302 in the above embodiments, which traverse the table data of each group of adjacent columns to determine the structural relationship between the multiple groups of adjacent columns, are essentially a recursive process. In practical applications, after traversing the first and second columns and determining the structural relationship between the first and second columns, the third column can be traversed. At this time, the first adjacent column is the second column, and the second adjacent column is the third column. However, since the second column has already been traversed, there is no need to traverse the second column again; only the third column needs to be traversed. This process is essentially performing the same method on each column in turn (i.e., traversing each column to obtain the structural relationship between the current column and the previous column; since the first column does not have a previous column, only the first column is traversed), which is a recursive process.

[0094] In some embodiments, the first adjacent column includes a first independent cell, and the second adjacent column includes at least one second independent cell, wherein the first independent cell and the at least one second independent cell are subordinate to each other, and each second independent cell is parallel to the other; or, the first adjacent column includes at least one first independent cell, and the second adjacent column includes at least one second independent cell, wherein each first independent cell and the at least one second independent cell are subordinate to each other, and each first independent cell is parallel to the other, and each second independent cell is parallel to the other.

[0095] As an example, refer to Table 2. In Table 2, the first column is the first adjacent column and the second column is the second adjacent column. In this case, the first adjacent column includes one first independent cell and the second adjacent column includes at least one second independent cell. The first independent cell and at least one second independent cell have a subordinate relationship, and each second independent cell is parallel. If the second column in Table 2 is the first adjacent column and the third column is the second adjacent column, in this case, the first adjacent column includes at least one first independent cell and the second adjacent column includes at least one second independent cell. Each first independent cell and at least one second independent cell have a subordinate relationship, and each first independent cell is parallel. Each second independent cell is parallel.

[0096] In some embodiments, the step of traversing the table data of the first adjacent column and the second adjacent column respectively, determining at least one first independent cell in the first adjacent column based on the table data of the first adjacent column, and determining at least one second independent cell in the second adjacent column based on the table data of the second adjacent column, includes:

[0097] Perform the following operations on the first adjacent column and the second adjacent column respectively:

[0098] Record the row number of the table data in the first row of the current column as the starting row number, and iterate through the table data in the current column. When the table data is not empty, record the row number of the non-empty table data as the ending row number, and update the starting row number to the row number of the next row of the non-empty table data.

[0099] The sub-table corresponding to the starting row number, the sub-table corresponding to the ending row number, and all sub-tables between the starting row number and the ending row number are treated as a single cell, wherein the single cell includes a first single cell or a second single cell.

[0100] As an example, when iterating through the first and second adjacent columns, taking the first and second columns in Table 2 as examples, we first iterate through the first column. The table data of the sub-table in row 0 is empty. We define the starting row number A and record A as row 0. Then we continue to traverse downwards until the target data "Indicator 1" which is not empty appears in row 9. We define the ending row number B and record B as row 9. We treat all the sub-tables from row 0 to row 9 of the first column as the first independent cell and reset the starting row number A and the ending row number B.

[0101] Then, iterate through the second column. The data in the sub-table of row 0 is empty, so record the starting row number A as row 0. Continue iterating downwards until the target data "Indicator 1-1" appears in row 3, which is not empty. Record the ending row number B as row 3. Treat all sub-tables from row 0 to row 3 of the second column as a second independent cell, and reset the starting row number A and ending row number B. Continue iterating downwards until the data in the sub-table of row 4 is empty. Record the starting row number A as 4. Continue iterating until the target data "Indicator 1-2" appears in row 9, which is not empty. Record the ending row number B as row 9. Treat all sub-tables from row 4 to row 9 of the second column as a second independent cell.

[0102] In some embodiments, determining the row number of at least one independent cell includes:

[0103] All rows from the start row number to the end row number are counted as the row number of at least one independent cell.

[0104] As an example, in Table 2, the first independent cell in the first column has 9-0+1=10 rows, and the second independent cell in the second column has 3-0+1=4 rows and 9-4+1=6 rows respectively.

[0105] Then, since the first independent cell has 10 rows and row numbers 0-9, which is the same as the second independent cell (4+6=10 rows), and the row numbers 0-3 and 4-9 included in the second independent cell correspond to the row numbers of the first independent cell, the subordinate relationship between the first and second independent cells can be determined.

[0106] In some embodiments, see Figure 4 , Figure 4 This is a flowchart illustrating steps S401-S403 provided in the embodiments of this application. Figure 1 The step S103 shown can be implemented through steps S401-S403, which will be explained in conjunction with each step.

[0107] In step S401, at least one first set and at least one second set are constructed, wherein each first set is used to store a first independent cell and each second set is used to store a second independent cell.

[0108] Here, the first and second independent cells need to be stored as sets, and the inclusion relationships between the sets need to be determined to construct a tree-structured data. A first set is created to store the first independent cell, and a second set is created to store the second independent cell.

[0109] In step S402, each first independent cell is placed into the corresponding first set, and each second independent cell is placed into the corresponding second set.

[0110] Here, each first independent cell is placed into a first set, and each second independent cell is placed into a second set.

[0111] In step S403, the second set corresponding to the second independent cell with a subordinate relationship is determined as a subset of the first set corresponding to the first independent cell, and the first set corresponding to the first independent cell with a parallel relationship is determined as a parallel first set, and the second set corresponding to the second independent cell with a parallel relationship is determined as a parallel second set.

[0112] Here, based on the subordinate relationship between the first independent cell and the second independent cell obtained in the above embodiment, the second set corresponding to the second independent cell with the subordinate relationship can be determined as a subset of the first set corresponding to the first independent cell. The first set corresponding to the first independent cell with the parallel relationship can be determined as a parallel first set, and the second set corresponding to the second independent cell with the parallel relationship can be determined as a parallel second set. Taking the first column and the second column in Table 2 as examples, one first independent cell in the first column corresponds to one first set, and two second independent cells in the second column correspond to two second sets. The two second sets are parallel sets and are subsets of the first set.

[0113] In some embodiments, the method further includes:

[0114] The tree structure data is stored in a database, or a tree diagram corresponding to the tree structure data is generated based on the tree structure data.

[0115] Here, the obtained tree structure data is stored in the form of a set. In order to import the tree structure data stored in the form of a set into the database, the obtained tree structure data can be stored into the database through a Java program, and the tree structure in the database can be represented as a nested subset or an adjacency list.

[0116] In summary, the embodiments of this application have the following beneficial effects:

[0117] By reading the table data of each sub-table in a spreadsheet including vertically merged cells, and traversing the table data of each group of adjacent columns in the reading results, since the target data of the vertically merged cells is only read in the last row of the sub-table, and the table data of the other rows of the sub-tables are empty, the number of vertically merged cells in each column of each group of adjacent columns and the number of rows of each vertically merged cell can be determined. Based on this, the structural relationship between each group of adjacent column data can be determined by the correspondence between the row numbers. Since only one traversal of the reading results is needed to obtain the structural relationship between each group of adjacent column data, compared with the multiple traversals of the traditional method, the number of loops can be reduced, thus efficiently obtaining the tree structure data corresponding to at least one vertically merged cell.

[0118] Based on the same inventive concept, this application also provides a data processing device corresponding to the data processing method in the first embodiment. Since the principle of the device in this application is similar to that of the above-mentioned data processing method, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0119] like Figure 5 As shown, Figure 5This is a schematic diagram of the structure of the data processing apparatus 500 provided in an embodiment of this application. The data processing apparatus 500 includes:

[0120] The reading module 501 is used to read the table data of each sub-table in a spreadsheet that includes at least one vertically merged cell; wherein the table data of the last row of the sub-table in each vertically merged cell is determined according to the target data of the vertically merged cell, and the table data of the other rows of the sub-table in each vertically merged cell are null values.

[0121] The processing module 502 is used to acquire table data of multiple sets of adjacent columns, traverse the table data of each set of adjacent columns respectively, and determine the structural relationship between the multiple sets of adjacent columns of table data; wherein, the structural relationship includes the parallel relationship and the subordinate relationship between the table data.

[0122] The generation module 503 is used to generate tree structure data corresponding to the at least one vertically merged cell based on the table data and the structural relationship between the multiple sets of adjacent table data.

[0123] Those skilled in the art should understand that Figure 5 The functions of each unit in the data processing apparatus 500 shown can be understood by referring to the relevant description of the aforementioned data processing method. Figure 5 The functions of each unit in the data processing device 500 shown can be implemented by a program running on a processor or by specific logic circuits.

[0124] In one possible implementation, the reading module 501 reads the table data of each sub-table in the spreadsheet, including:

[0125] Construct a list set whose row and column lengths correspond to the row and column lengths of the spreadsheet;

[0126] Read the table data of each sub-table in the spreadsheet, and each sub-table corresponds to a reading result;

[0127] The read results are placed into the list set, wherein the row and column positions of each read result in the list set correspond to the row and column positions of the data in each cell of the spreadsheet.

[0128] In one possible implementation, the processing module 502 traverses the table data of each group of adjacent columns to determine the structural relationship between the multiple groups of adjacent columns of table data, including:

[0129] The table data of the first adjacent column and the second adjacent column are traversed respectively. Based on the table data of the first adjacent column, at least one first independent cell in the first adjacent column is determined, and based on the table data of the second adjacent column, at least one second independent cell in the second adjacent column is determined.

[0130] Determine the first row number of the at least one first independent cell, and the second row number of the at least one second independent cell;

[0131] The parallel relationship between the first independent cells is determined based on the number of at least one first row, and the parallel relationship between the at least one second independent cells is determined based on the number of at least one second row; and the subordinate relationship between at least one first independent cell and at least one second independent cell is determined based on the number of at least one first row and the number of at least one second row.

[0132] In one possible implementation, the processing module 502 traverses the table data of the first adjacent column and the second adjacent column respectively, determines at least one first independent cell in the first adjacent column based on the table data of the first adjacent column, and determines at least one second independent cell in the second adjacent column based on the table data of the second adjacent column, including:

[0133] Perform the following operations on the first adjacent column and the second adjacent column respectively:

[0134] Record the row number of the table data in the first row of the current column as the starting row number, and iterate through the table data in the current column. When the table data is not empty, record the row number of the non-empty table data as the ending row number, and update the starting row number to the row number of the next row of the non-empty table data.

[0135] The sub-table corresponding to the starting row number, the sub-table corresponding to the ending row number, and all sub-tables between the starting row number and the ending row number are treated as an independent cell, wherein the independent cell includes a first independent cell or a second independent cell;

[0136] Determine the row number of at least one independent cell, including:

[0137] All rows from the start row number to the end row number are counted as the row number of at least one independent cell.

[0138] In one possible implementation, the generation module 503 generates tree structure data corresponding to the at least one vertically merged cell based on the table data and the structural relationships between the multiple sets of adjacent table data, including:

[0139] Construct at least one first set and at least one second set, wherein each first set is used to store a first independent cell and each second set is used to store a second independent cell;

[0140] Place each first independent cell into its corresponding first set, and place each second independent cell into its corresponding second set;

[0141] The second set corresponding to the second independent cell with a subordinate relationship is determined as a subset of the first set corresponding to the first independent cell, and the first set corresponding to the first independent cell with a parallel relationship is determined as a parallel first set, and the second set corresponding to the second independent cell with a parallel relationship is determined as a parallel second set.

[0142] In one possible implementation, the generation module 503 further includes:

[0143] The tree structure data is stored in a database, or a tree diagram corresponding to the tree structure data is generated based on the tree structure data.

[0144] The aforementioned data processing device reads the table data of each sub-table in a spreadsheet including vertically merged cells, and iterates through the table data of each group of adjacent columns in the reading result. Since the target data is only read in the last row of the sub-table of the vertically merged cells, and the table data of other rows of the sub-tables are empty, the number of vertically merged cells in each column of each group of adjacent columns and the number of rows of each vertically merged cell can be determined. Based on this, the structural relationship between each group of adjacent column data can be determined through the correspondence between the row numbers. Since the structural relationship between each group of adjacent column data can be obtained by only one traversal of the reading result, compared with the multiple traversals of the traditional method, the number of loops can be reduced, thereby efficiently obtaining the tree structure data corresponding to at least one vertically merged cell.

[0145] like Figure 6 As shown, Figure 6 This is a schematic diagram of the composition structure of the electronic device 600 provided in the embodiments of this application. The electronic device 600 includes:

[0146] The device 600 includes a processor 601, a storage medium 602, and a bus 603. The storage medium 602 stores machine-readable instructions that can be executed by the processor 601. When the electronic device 600 is running, the processor 601 communicates with the storage medium 602 via the bus 603. The processor 601 executes the machine-readable instructions to perform the steps of the data processing method described in the embodiments of this application.

[0147] In practical applications, the various components in the electronic device 600 are coupled together via a bus 603. It is understood that the bus 603 is used to achieve communication between these components. In addition to a data bus, the bus 603 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 6 The general designated all buses as Bus 603.

[0148] The aforementioned electronic device reads the table data of each sub-table in a spreadsheet including vertically merged cells, and iterates through the table data of each group of adjacent columns in the reading result. Since the target data is only read in the last row of the sub-table of the vertically merged cells, and the table data of other rows of the sub-tables are empty, the number of vertically merged cells in each column of each group of adjacent columns and the number of rows of each vertically merged cell can be determined. Based on this, the structural relationship between each group of adjacent column data can be determined through the correspondence between the row numbers. Since only one traversal of the reading result is needed to obtain the structural relationship between each group of adjacent column data, compared with the multiple traversals of the traditional method, the number of loops can be reduced, thereby efficiently obtaining the tree structure data corresponding to at least one vertically merged cell.

[0149] This application also provides a computer-readable storage medium storing executable instructions that, when executed by at least one processor 801, implement the data processing method described in this application.

[0150] In some embodiments, the storage medium may be a magnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM), etc.; or it may be a device that includes one or any combination of the above-mentioned memories.

[0151] In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.

[0152] As an example, executable instructions may, but do not necessarily, correspond to files in the file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborating files (e.g., a file that stores one or more modules, subroutines, or code sections).

[0153] As an example, executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.

[0154] The aforementioned computer-readable storage medium reads the table data of each sub-table in a spreadsheet including vertically merged cells, and traverses the table data of each group of adjacent columns in the read result. Since the target data is only read in the last row of the sub-table of the vertically merged cells, and the table data of other rows of the sub-tables are empty, the number of vertically merged cells in each column of each group of adjacent columns and the number of rows of each vertically merged cell can be determined. Based on this, the structural relationship between each group of adjacent column data can be determined through the correspondence between the row numbers. Since the structural relationship between each group of adjacent column data can be obtained by only traversing the read result once, compared with the multiple traversals of the traditional method, the number of loops can be reduced, thereby efficiently obtaining the tree structure data corresponding to at least one vertically merged cell.

[0155] In the several embodiments provided in this application, it should be understood that the disclosed methods and electronic devices can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components may be combined, or integrated into another system, or some features may be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0156] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0157] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0158] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a platform server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0159] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A data processing method, characterized in that, Includes the following steps: For a spreadsheet that includes at least one vertically merged cell, the table data of each sub-table in the spreadsheet is read; wherein, the table data of the last row of the sub-table of each vertically merged cell is determined according to the target data of the vertically merged cell, and the table data of the other rows of the sub-table of each vertically merged cell are empty; Obtain table data from multiple sets of adjacent columns, traverse the table data from each set of adjacent columns respectively, and determine the structural relationship between the multiple sets of adjacent columns of table data; wherein, the structural relationship includes the parallel relationship and the subordinate relationship between the table data; Based on the table data and the structural relationship between the multiple sets of adjacent table data, a tree structure data corresponding to the at least one vertically merged cell is generated. Each group of adjacent columns includes a first adjacent column and a second adjacent column; the step of traversing the table data of each group of adjacent columns to determine the structural relationship between the multiple groups of adjacent column data includes: The table data of the first adjacent column and the second adjacent column are traversed respectively. Based on the table data of the first adjacent column, at least one first independent cell in the first adjacent column is determined, and based on the table data of the second adjacent column, at least one second independent cell in the second adjacent column is determined. Determine the first row number of the at least one first independent cell, and the second row number of the at least one second independent cell; The parallel relationship between the first independent cells is determined based on the first row number of the at least one first independent cell, and the parallel relationship between the at least one second independent cell is determined based on the second row number of the at least one second independent cell; and the subordinate relationship between the at least one first independent cell and the at least one second independent cell is determined based on the first row number of the at least one first independent cell and the second row number of the at least one second independent cell. The step of generating tree structure data corresponding to the at least one vertically merged cell based on the table data and the structural relationships between the multiple sets of adjacent table data includes: Construct at least one first set and at least one second set, wherein each first set is used to store a first independent cell and each second set is used to store a second independent cell; Place each first independent cell into its corresponding first set, and place each second independent cell into its corresponding second set; The second set corresponding to the second independent cell with a subordinate relationship is determined as a subset of the first set corresponding to the first independent cell, and the first set corresponding to the first independent cell with a parallel relationship is determined as a parallel first set, and the second set corresponding to the second independent cell with a parallel relationship is determined as a parallel second set.

2. The method according to claim 1, characterized in that, The step of reading the table data of each sub-table in the spreadsheet includes: Construct a list set whose row and column lengths correspond to the row and column lengths of the spreadsheet; Read the table data of each sub-table in the spreadsheet, and each sub-table corresponds to a reading result; The read results are placed into the list set, wherein the row and column positions of each read result in the list set correspond to the row and column positions of the data in each sub-table of the spreadsheet.

3. The method according to claim 1, characterized in that, The first adjacent column includes a first independent cell, and the second adjacent column includes at least one second independent cell. The first independent cell and the at least one second independent cell have a subordinate relationship, and each second independent cell is parallel to the other. Alternatively, the first adjacent column includes at least one first independent cell, and the second adjacent column includes at least one second independent cell. Each first independent cell and the at least one second independent cell have a subordinate relationship, and each first independent cell is parallel to the other. Each second independent cell is parallel to the other.

4. The method according to claim 1, characterized in that, The step of traversing the table data of the first adjacent column and the second adjacent column respectively, determining at least one first independent cell in the first adjacent column based on the table data of the first adjacent column, and determining at least one second independent cell in the second adjacent column based on the table data of the second adjacent column, includes: Perform the following operations on the first adjacent column and the second adjacent column respectively: Record the row number of the table data in the first row of the current column as the starting row number, and iterate through the table data in the current column. When the table data is not empty, record the row number of the non-empty table data as the ending row number, and update the starting row number to the row number of the next row of the non-empty table data. The sub-table corresponding to the starting row number, the sub-table corresponding to the ending row number, and all sub-tables between the starting row number and the ending row number are treated as an independent cell, wherein the independent cell includes a first independent cell or a second independent cell; Determine the row number of at least one independent cell, including: All rows from the start row number to the end row number are counted as the row number of at least one independent cell.

5. The method according to claim 1, characterized in that, The method further includes: The tree structure data is stored in a database, or a tree diagram corresponding to the tree structure data is generated based on the tree structure data.

6. A data processing apparatus, characterized in that, The device includes: The reading module is used to read the table data of each sub-table in a spreadsheet that includes at least one vertically merged cell; wherein the table data of the last row of the sub-table in each vertically merged cell is determined according to the target data of the vertically merged cell, and the table data of the other rows of the sub-table in each vertically merged cell are empty. A processing module is used to acquire table data of multiple sets of adjacent columns, traverse the table data of each set of adjacent columns respectively, and determine the structural relationship between the multiple sets of adjacent column table data; wherein, the structural relationship includes the parallel relationship and the subordinate relationship between the table data; each set of adjacent columns includes a first adjacent column and a second adjacent column; the step of traversing the table data of each set of adjacent columns respectively to determine the structural relationship between the multiple sets of adjacent column table data includes: traversing the table data of the first adjacent column and the second adjacent column respectively; determining at least one first independent cell in the first adjacent column based on the table data of the first adjacent column, and determining at least one second independent cell in the second adjacent column based on the table data of the second adjacent column; determining the first row number of the at least one first independent cell and the second row number of the at least one second independent cell; determining the parallel relationship between the first independent cells based on the first row number of the at least one first independent cell, and determining the parallel relationship between the at least one second independent cell based on the second row number of the at least one second independent cell; and determining the subordinate relationship between the at least one first independent cell and the at least one second independent cell based on the first row number of the at least one first independent cell and the second row number of the at least one second independent cell. A generation module is used to generate tree structure data corresponding to the at least one vertically merged cell based on the table data and the structural relationship between the multiple sets of adjacent table data. The generation of the tree structure data corresponding to the at least one vertically merged cell based on the table data and the structural relationship between the multiple sets of adjacent table data includes: constructing at least one first set and at least one second set, wherein each first set is used to store one first independent cell, and each second set is used to store one second independent cell; placing each first independent cell into its corresponding first set, and placing each second independent cell into its corresponding second set; determining the second set corresponding to the second independent cells with a subordinate relationship as a subset of the first set corresponding to the first independent cells, and determining the first set corresponding to the first independent cells with a parallel relationship as a parallel first set, and determining the second set corresponding to the second independent cells with a parallel relationship as a parallel second set.

7. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is in operation, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the data processing method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the data processing method as described in any one of claims 1 to 5.