Table cell merging method and device, medium and equipment

By sorting the table data and determining the merge parameters using recursive functions in Web front-end development, automated table cell merging is achieved, solving the problem of redundancy of duplicate data in traditional table data display, and improving user experience and development efficiency.

CN119849455AActive Publication Date: 2025-04-18SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411778384.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-04-18
Estimated Expiration
2044-12-05

AI Technical Summary

Technical Problem

In web front-end development, traditional tabular data display will directly list all data, resulting in a large amount of duplicate data redundancy, affecting user reading efficiency, and cell merging is required to simplify the display effect.

Method used

By sorting the data of each row in the table as a reference field, using a recursive function to determine the merge parameters of each group of cells that need to be merged in the reference field, including the starting position and the number of rows across rows, and merging cells based on these parameters.

Benefits of technology

It realizes automatic calculation of the position and number of merged cells, avoids manual errors, improves the efficiency and accuracy of data display, enhances user experience, and simplifies development work.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119849455A_ABST
    Figure CN119849455A_ABST
Patent Text Reader

Abstract

The invention provides a table cell merging method and device, a medium and equipment. The method comprises the following steps: taking a field needing to be subjected to cell merging in a table as a reference field; taking each row of data in the table as a piece of data, determining the sorting attribute of the piece of data according to the key value of the reference field in each piece of data, and sorting each piece of data in the table according to the respective sorting attribute of each piece of data in the table to obtain a sorted list; determining merging parameters of each group of cells needing to be merged in the reference fields in the sorted list by adopting a recursive function; wherein the merging parameters comprise an initial position and a cross-row line number; and merging the group of cells according to the merging parameters of each group of cells needing to be merged. According to the method, the cell merging efficiency and accuracy can be improved, the workload of developers is simplified, and the attractiveness and the readability of a table on a user interface can be improved through cell merging.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of table processing, and in particular to a table cell merging method, device, medium and equipment. Background Art

[0002] In the process of Web front-end development, it is often necessary to merge the data in the table to simplify the display effect and improve the user reading experience. Traditional table data display usually lists all the data directly. When encountering a large amount of repeated data, it not only appears redundant, but also affects the user's reading efficiency. Therefore, cell merging is required. Summary of the invention

[0003] In view of at least one of the above technical problems, an embodiment of the present invention provides a table cell merging method, device, medium, and equipment.

[0004] According to the first aspect, the table cell merging method provided by the embodiment of the present invention includes:

[0005] Use the field in the table that needs to be merged as the reference field;

[0006] Taking each row of data in the table as a piece of data, determining the sorting attribute of the piece of data according to the key value of the reference field in each piece of data, and sorting the pieces of data in the table according to the respective sorting attributes of the pieces of data in the table to obtain a sorted list;

[0007] A recursive function is used to determine the merge parameters of each group of cells to be merged in the reference field in the sorted list; wherein the merge parameters include a starting position and a number of rows spanned;

[0008] Merge each group of cells according to the merge parameters of the group of cells to be merged.

[0009] In one embodiment, determining the sorting attribute of each piece of data according to the key value of the reference field in the data includes:

[0010] Convert the key value of each reference field in each data entry in the table into a string of fixed length by padding with zeros;

[0011] If there are multiple reference fields, the fixed-length strings corresponding to the key values ​​of each reference field in each piece of data are concatenated, and the resulting concatenated string is used as the sorting attribute corresponding to the data; if there are 1 reference fields, the fixed-length strings corresponding to the key values ​​of each reference field in each piece of data are used as the sorting attribute corresponding to the data.

[0012] In one embodiment, converting the key value of each reference field in each piece of data in the table into a string of fixed length by padding with zeros includes:

[0013] If the key value of the reference field is a numerical value, zeros are added to the front of the key value of the reference field to obtain data of a fixed length and then converted into a string format.

[0014] In one embodiment, converting the key value of each reference field in each piece of data in the table into a string of fixed length by padding with zeros includes:

[0015] If the key value of the reference field is a numeric value, subtract the key value of the reference field from 10*(n+1) to obtain a first value, pad the front of the first value with zeros, obtain data of a fixed length and convert it into a string format; wherein n is the maximum length of the key value of the reference field in each piece of data.

[0016] In one embodiment, the step of using a recursive function to determine the merge parameters of each group of cells to be merged in the reference field in the sorted list includes:

[0017] S1. Put each reference field into the first array from largest to smallest;

[0018] S2. define a first object, where the initial value of the first object is empty;

[0019] S3. Let the initial value of integer i be 1;

[0020] S4. Execute the following steps S41 to S45 for the i-th data in the sorted list:

[0021] S41, let the initial value of integer j be 1;

[0022] S42, taking out the jth reference field from the first array, and checking whether the key value of the jth reference field in the data exists in the first object;

[0023] S43, if it does not exist, create a new sorting element item in the first object, the sorting element item has two attributes, the two attributes including the starting position of the merged cell and the number of rows spanned; assign the row index of the data to the starting position of the sorting element item, and set the number of rows spanned by the sorting element item to 1; if it exists, increase the number of rows spanned by the sorting element item corresponding to the data by 1;

[0024] S44, determining whether j is equal to m, where m is the number of reference fields in the first array;

[0025] S45, if j is less than m, add 1 to j and return to S42;

[0026] S5. If j is equal to m, determine whether i is equal to the total number of data in the sorted list; if so, exit the process and use the sorting element items in the first object as the merging parameters of the groups of cells that need to be merged; otherwise, set i+1 and repeat S4.

[0027] In one embodiment, placing each reference field into the first array from largest to smallest includes:

[0028] If there is a hierarchical relationship between the reference fields, the reference fields are placed in the first array from large to small according to the hierarchical relationship; if there is no hierarchical relationship between the reference fields, the reference fields are placed in the first array from large to small according to the order of the reference fields in the sorted list.

[0029] In one embodiment, the merging of each group of cells to be merged according to the merging parameters of the group of cells to be merged includes:

[0030] According to the starting position in each sorting element item, the corresponding cell in the sorted list is determined, and the cross-row attribute of the cell is set to the number of cross-rows in the sorting element item to realize the merging of cells starting from the starting position and downward by the number of cross-rows.

[0031] According to a second aspect, a table cell merging device provided by an embodiment of the present invention includes:

[0032] A field determination module is used to use the field in the table that needs to be merged as a reference field;

[0033] A table sorting module, used to treat each row of data in the table as a piece of data, determine the sorting attribute of the piece of data according to the key value of the reference field in each piece of data, and sort the pieces of data in the table according to their respective sorting attributes to obtain a sorted list;

[0034] A parameter determination module, used for determining the merging parameters of each group of cells to be merged in the reference field in the sorted list by using a recursive function; wherein the merging parameters include a starting position and a number of rows spanned;

[0035] The cell merging module is used to merge a group of cells according to the merging parameters of each group of cells to be merged.

[0036] According to a third aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, enables the computer to execute the method provided in the first aspect.

[0037] According to a fourth aspect, an embodiment of the present invention provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method provided in the first aspect is implemented.

[0038] The table cell merging method, device, medium and equipment provided by the embodiment of the present invention take the field in the table that needs to be merged as the reference field, take each row of data in the table as a piece of data, determine the sorting attribute of the data according to the key value of the reference field in each piece of data, and sort the data in the table according to the sorting attributes of each piece of data in the table, obtain the sorted list, and then use a recursive function to determine the starting position and the number of rows across each group of cells that need to be merged in the reference field in the sorted list, and finally merge the group of cells according to the merging parameters of each group of cells that need to be merged. It can be seen that in the embodiment of the present invention, the data in the list are first sorted so that the same cells in the column corresponding to the reference field are in the form of continuous arrangement, and then the recursive algorithm is used to automatically calculate the starting position and the number of rows across the cells that need to be merged in the arranged list, and then the cells are merged according to the starting position and the number of rows across the rows. The whole process does not require manual participation, can improve the efficiency and accuracy of cell merging, can simplify the workload of developers, and can improve the aesthetics and readability of the table in the user interface through cell merging, improve user experience, and be easy to maintain and expand. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a flowchart of a method for merging table cells in one embodiment of the present invention;

[0040] Figure 2 4 is a structural block diagram of a table cell merging device in one embodiment of the present invention. DETAILED DESCRIPTION

[0041] In a first aspect, an embodiment of the present invention provides a method for merging table cells, see Figure 1 The method comprises the following steps S110 to S140:

[0042] S110, taking the field in the table that needs to be merged as a reference field;

[0043] For example, see Table 1 below. A table includes three columns, and the field names are "province", "city", and "county". There are 11 rows of data in the list, that is, there are 11 data in total. Since in the list, there are several cells in the "province" column that are "Beijing" and several cells that are "Shandong Province"; in the list, there are several cells in the "city" column that are "Beijing", several cells that are "Jinan", and several cells that are "Qingdao", the fields in the "province" and "city" columns can be used as reference fields, that is, the reference fields are "province" and "city".

[0044] Table 1 Tables that need to be merged

[0045] Province city county Beijing Beijing Chaoyang District Shandong Province Qingdao Shinan District Beijing Beijing Haidian District Shandong Province Qingdao Licang District Shandong Province Jinan Lixia District Shandong Province Qingdao Jiaozhou City Beijing Beijing Dongcheng District Beijing Beijing Xicheng District Shandong Province Jinan Licheng District Shandong Province Jinan Shizhong District Shandong Province Jinan Pingyin County

[0046] S120, taking each row of data in the table as a piece of data, determining a sorting attribute of the piece of data according to a key value of the reference field in each piece of data, and sorting each piece of data in the table according to the respective sorting attributes of each piece of data in the table to obtain a sorted list;

[0047] It can be seen that, by sorting the data in the table in S120 , the same cells in the column corresponding to the reference field are arranged continuously, thereby facilitating the subsequent merging of the same cells.

[0048] In one embodiment, determining the sorting attribute of each piece of data according to the key value of the reference field in each piece of data in S120 may include S121 to S122:

[0049] S121, converting the key value of each reference field in each piece of data in the table into a string of fixed length by padding with zeros;

[0050] S122. If there are multiple reference fields, the fixed-length character strings corresponding to the key values ​​of each reference field in each piece of data are concatenated, and the obtained concatenated character string is used as the sorting attribute corresponding to the data; if the number of reference fields is 1, the fixed-length character strings corresponding to the key values ​​of each reference field in each piece of data are used as the sorting attribute corresponding to the data.

[0051] For example, if the reference fields are a, b, and c, and the key value Va of the reference field a in each data item is a number or a string of numbers, and the subsequent sorting is in ascending order, you can pad the key value with zeros to make it a fixed length. This can be achieved through the following function: Va' = Va.toString().padStart(n,'0').

[0052] It can be seen that the conversion of the key value of each reference field in each data in the table into a fixed-length string by padding with zeros described in S121 may include: if the key value of the reference field is a numerical value, padding with zeros in front of the key value of the reference field to obtain fixed-length data and then converting it into a string format.

[0053] Of course, if the subsequent sorting is in descending order, you can first subtract a large number to reverse its size, and then pad it with zeros to make its length consistent. This can be achieved through the following function: Va'=(10*(n+1)-Number(Va)).toString().padStart(n,'0').

[0054] It can be seen that the step of converting the key value of each reference field in each piece of data in the table into a string of fixed length by padding with zeros as described in S121 may include: if the key value of the reference field is a numerical value, subtracting the key value of the reference field from 10*(n+1) to obtain a first value, padding with zeros in front of the first value to obtain data of a fixed length and then converting the data into a string format; wherein n is the maximum length of the key value of the reference field in each piece of data.

[0055] The fixed length is n in the above function.

[0056] Among them, toString() refers to a function that converts a numeric value into a string.

[0057] Among them, padStart(n,'0') refers to a function that fills 0 in front of the data to make it reach a length of n.

[0058] The sorting attribute in S122 can be recorded as sortid, and each piece of data has a sortid. For the above example, the sortid of a piece of data is the concatenation result of Va', Vb' and Vc'.

[0059] After calculating the sortid of each data in the table, the data can be sorted according to the sortid. The sorting can be implemented by the following function: list.sort((r1, r2)=>r1.sortId.localeCompare(r2.sortId)), where r1 and r2 are two data. It can be seen that in this function, the Unicode codes of the sortid of the two data are compared according to localeCompare to determine the order of the Unicode codes, and then the sorting is performed by the sort function.

[0060] Among them, localeCompare() is the comparison function.

[0061] Among them, sort is the sorting function.

[0062] Among them, l ist is the table that needs to be sorted.

[0063] It can be seen that after sorting, the following Table 2 is obtained: in the "City" column, all the data of Beijing are arranged continuously, all the data of Jinan are arranged continuously, and all the data of Qingdao are arranged continuously. Moreover, in the "Province" column, all the data of Beijing are arranged together, and all the data of Shandong Province are arranged together.

[0064] Table 2 Sorted list

[0065]

[0066]

[0067] S130, using a recursive function to determine the merge parameters of each group of cells to be merged in the reference field in the sorted list; wherein the merge parameters include a starting position and a number of rows across;

[0068] In other words, for each column corresponding to a reference field, it is necessary to determine the starting position and number of rows of each cell to be merged.

[0069] In one embodiment, the use of a recursive function in S130 to determine the merge parameters of each group of cells to be merged in the reference field in the sorted list may include S1 to S5:

[0070] S1. Put each reference field into the first array from largest to smallest;

[0071] For example, the first array is recorded as category, and the two reference fields "province" and "city" are placed in the first array. At this time, there are two elements in the first array.

[0072] In one embodiment, the step of placing each reference field from large to small into the first array in S1 may include: if there is a hierarchical relationship between the reference fields, placing each reference field from large to small into the first array according to the hierarchical relationship; if there is no hierarchical relationship between the reference fields, placing each reference field from large to small into the first array according to the order of the reference fields in the sorted list.

[0073] That is, placing reference fields with higher levels at the front of the first array, or placing reference fields that are ranked first in the sorted list at the front of the first array, helps to execute recursive functions and avoid confusion.

[0074] S2. define a first object, where the initial value of the first object is empty;

[0075] For example, the first object is recorded as sortObj={}, which is empty at the beginning.

[0076] S3. Let the initial value of integer i be 1;

[0077] Among them, i represents the row index of each data in the sorted list.

[0078] S4. Execute the following steps S41 to S45 for the i-th data in the sorted list:

[0079] S41, let the initial value of integer j be 1;

[0080] Wherein, j is the index of the reference field in the first array.

[0081] For example, category includes two elements: "province" and "city", the j of the element "province" is 1, and the j of the element "city" is 2. The initial value of j is 1, and the following steps are performed for the reference field "province".

[0082] S42, taking out the jth reference field from the first array, and checking whether the key value of the jth reference field in the data exists in the first object;

[0083] S43, if it does not exist, create a new sorting element item in the first object, the sorting element item has two attributes, the two attributes including the starting position of the merged cell and the number of rows spanned; assign the row index of the data to the starting position of the sorting element item, and set the number of rows spanned by the sorting element item to 1; if it exists, increase the number of rows spanned by the sorting element item corresponding to the data by 1;

[0084] For example, when i is 1 and j is 1, the row index is 1, and the data is the first row of the "province" column in the sorted list, and the data item is the cell "Beijing" in the "province" column, that is, the data item is "Beijing". The key value of the first reference field in this data is "Beijing". Since the first object is empty at this time, it does not exist in the first object "Beijing". At this time, add a sorting element item to the first object, and the starting position attribute of this sorting element item is set to row index 1, and the number of rows across rows attribute is set to 1.

[0085] It is understandable that new sorting elements need to be added at the beginning. When executing to the subsequent rows, new sorting elements may or may not be needed. If the key value of the jth reference field in the ith data exists in the first object, it means that the key values ​​of the ith data and the i-1th data in the jth reference field are the same. At this time, there is no need to create a new sorting element, but to add 1 to the value of the cross-row number attribute of the corresponding sorting element in the first object.

[0086] S44, determining whether j is equal to m, where m is the number of reference fields in the first array;

[0087] S45, if j is less than m, add 1 to j and return to S42;

[0088] S5. If j is equal to m, determine whether i is equal to the total number of data in the sorted list; if so, exit the process and use the sorting element items in the first object as the merging parameters of the groups of cells that need to be merged; otherwise, set i+1 and repeat S4.

[0089] It can be seen that for each piece of data, it is necessary to traverse all the reference fields in the first array before executing the steps corresponding to the next piece of data. That is, when j = the number of reference fields in the first array, jump out of S41 to S45. If i is less than the total number of data in the sorted list at this time, i is increased by 1, so that S41 to S45 are executed for the next piece of data. If i is equal to the total number of data in the sorted list, it means that the data is the last row of data in the sorted list at this time, and each sorting element item stored in the first object is output.

[0090] For example, there are five sorting elements stored in the first object: In the "Province" column, the four cells with the key value "Beijing" need to be merged, so they correspond to one sorting element, and the seven cells with the key value "Shandong Province" need to be merged, so they correspond to one sorting element. In the "City" column, the four cells with the key value "Beijing" need to be merged, so they correspond to one sorting element, the four cells with the key value "Jinan" need to be merged, so they correspond to one sorting element, and the three cells with the key value "Qingdao" need to be merged, so they correspond to one sorting element.

[0091] Of course, when the key value of a cell in a column is different from the key values ​​of other cells, that is, when a cell is different from other cells in the column, there will also be a sorting element item, but the cross-row number attribute in the sorting element item is 1, which shows that the cells will not be merged.

[0092] The sorting element item is recorded as sortItem, which contains the following two attributes:

[0093] (1) index: indicates the starting position of the merged cell;

[0094] (2)rowspan: indicates the number of rows spanned by the merged cells.

[0095] Among them, the recursive function can be recorded as mergeCell(item,index,obj,category).

[0096] The parameters have the following meanings:

[0097] item: the i-th data in the sorted list;

[0098] index: the row index of item in the sorted list;

[0099] obj: first object;

[0100] category: The first array, which is an array consisting of the parameter names of each reference field.

[0101] S140. Merge each group of cells according to the merge parameters of the group of cells to be merged.

[0102] It can be seen that after obtaining the starting position and the number of rows across each group of cells to be merged in the reference field in S130, the cells can be merged. For example, after the cells are merged, the following table is obtained.

[0103] Table 3 Merged list

[0104]

[0105] In one embodiment, the step S140 of merging each group of cells to be merged according to the merging parameters of the group of cells to be merged may include:

[0106] According to the starting position in each sorting element item, the corresponding cell in the sorted list is determined, and the cross-row attribute of the cell is set to the number of cross-rows in the sorting element item to realize the merging of cells starting from the starting position and downward by the number of cross-rows.

[0107] It can be seen that according to the starting position in each sorting element item, the corresponding cell in the sorted list can be found, and the span attribute of the cell is set to the number of spans in the sorting element item. In this way, the cell and the (number of spans - 1) cells below the cell will be merged into one cell, and the content of the merged cell is the content of the cell corresponding to the starting position.

[0108] The row span attribute of a cell is rowspan. The rowspan attribute is an object attribute in the HTML language, which is mainly used to implement the row span function of cells in a table. When the rowspan attribute is used in the td tag, the number of rows spanned by a cell can be specified, thereby achieving the effect of a column spanning multiple rows. td is an HTML tag that represents a cell in an HTML table.

[0109] Among them, when determining the corresponding cell in the sorted list where the starting position is needed, the corresponding cell is obtained through the nested method of sortObj[item.province], sortObj[item.province][item.city]. The reason for adopting such a hierarchical nesting method is to avoid data confusion when there are the same cells in different columns. For example, there is a city x under Beijing, and there is also a city x under Shandong Province. If the data to be processed later are all placed at the same level, the information processed and saved first will be overwritten, resulting in data confusion.

[0110] The embodiments of the present invention have the following beneficial effects:

[0111] (1) Improve the efficiency and accuracy of data display: By automatically calculating the position of merged cells and the number of rows spanned, human errors that may occur when manually setting the rowspan attribute are avoided, ensuring the correct display of table data.

[0112] (2) Enhanced user experience: By merging duplicate data, the visual redundancy of the table is reduced, making the table more concise and clear, and improving the user's reading experience.

[0113] (3) Simplifying development work: The method provided by the present invention simplifies the workflow of developers when processing table data merging, reduces the complexity of the code, and makes the development process more efficient.

[0114] (4) Easy to maintain and expand: Since the method of the present invention is based on clear logic and algorithms, subsequent maintenance and functional expansion become simpler and easy to adapt to different business demand changes. Through recursive algorithms, it can be easily expanded to multi-level data merging scenarios.

[0115] (5) Support flexible data sorting: The present invention supports multiple data sorting methods to meet the display requirements in different scenarios.

[0116] (6) Improving the readability and reusability of the code: The method of the present invention clearly defines the logic of data sorting and merging, making the code easy to understand and having high reuse value, which helps to improve the overall quality of the project.

[0117] In summary, the present invention aims to provide a method for merging table data on a Web front end, which can automatically calculate the starting position and the number of cross-rows of cells to be merged in the table by using a recursive algorithm, improve the accuracy and efficiency of table data merging, reduce maintenance costs, and enhance the aesthetics and readability of the user interface, which can significantly simplify the workload of developers while ensuring the consistency and accuracy of data display.

[0118] In a second aspect, an embodiment of the present invention provides a table cell merging device, see Figure 2 , the device 100 comprises:

[0119] A field determination module 110 is used to use the field in the table that needs to be merged as a reference field;

[0120] The table sorting module 120 is used to treat each row of data in the table as a piece of data, determine the sorting attribute of the piece of data according to the key value of the reference field in each piece of data, and sort the pieces of data in the table according to their respective sorting attributes to obtain a sorted list;

[0121] The parameter determination module 130 is used to determine the merge parameters of each group of cells to be merged in the reference field in the sorted list by using a recursive function; wherein the merge parameters include a starting position and a number of rows across;

[0122] The cell merging module 140 is used to merge each group of cells according to the merging parameters of the group of cells to be merged.

[0123] In one embodiment, the table sorting module includes:

[0124] A leading zero-padding unit, used to convert the key value of each reference field in each data in the table into a character string of fixed length by zero-padding;

[0125] The attribute determination unit is used to, if the number of the reference fields is multiple, concatenate the fixed-length character strings corresponding to the key values ​​of each reference field in each piece of data, and use the obtained concatenated character string as the sorting attribute corresponding to the data; if the number of the reference fields is 1, then use the fixed-length character strings corresponding to the key values ​​of each reference field in each piece of data as the sorting attribute corresponding to the data.

[0126] In one embodiment, the leading zero-padding unit is specifically used for: if the key value of the reference field is a numerical value, padding the leading zero value in front of the key value of the reference field to obtain data of a fixed length and then converting the data into a string format.

[0127] In one embodiment, the leading zero-padding unit is specifically used for: if the key value of the reference field is a numerical value, then 10*(n+1) is subtracted from the key value of the reference field to obtain a first value, zero-padding is performed in front of the first value, and the data of a fixed length is obtained and then converted into a string format; wherein n is the maximum length of the key value of the reference field in each piece of data.

[0128] In one embodiment, the parameter determination module is specifically configured to perform the following steps:

[0129] S1. Put each reference field into the first array from largest to smallest;

[0130] S2. define a first object, where the initial value of the first object is empty;

[0131] S3. Let the initial value of integer i be 1;

[0132] S4. Execute the following steps S41 to S45 for the i-th data in the sorted list:

[0133] S41, let the initial value of integer j be 1;

[0134] S42, taking out the jth reference field from the first array, and checking whether the key value of the jth reference field in the data exists in the first object;

[0135] S43, if it does not exist, create a new sorting element item in the first object, the sorting element item has two attributes, the two attributes including the starting position of the merged cell and the number of rows spanned; assign the row index of the data to the starting position of the sorting element item, and set the number of rows spanned by the sorting element item to 1; if it exists, increase the number of rows spanned by the sorting element item corresponding to the data by 1;

[0136] S44, determining whether j is equal to m, where m is the number of reference fields in the first array;

[0137] S45, if j is less than m, add 1 to j and return to S42;

[0138] S5. If j is equal to m, determine whether i is equal to the total number of data in the sorted list; if so, exit the process and use the sorting element items in the first object as the merging parameters of the groups of cells that need to be merged; otherwise, set i+1 and repeat S4.

[0139] In one embodiment, the process of placing each reference field from large to small into the first array in the parameter determination module includes: if there is a hierarchical relationship between the reference fields, then placing each reference field from large to small into the first array according to the hierarchical relationship; if there is no hierarchical relationship between the reference fields, then placing each reference field from large to small into the first array according to the order of the reference fields in the sorted list.

[0140] In one embodiment, the cell merging module is specifically used to: determine the corresponding cell in the sorted list according to the starting position in each sorting element item, set the cross-row attribute of the cell to the number of cross-rows in the sorting element item, so as to realize the merging of cells starting from the starting position and downward by the number of cross-rows.

[0141] It is understandable that the explanation, specific implementation, beneficial effects, examples, etc. of the relevant contents in the device provided in the embodiment of the present invention can be found in the corresponding parts of the method provided in the first aspect, and will not be repeated here.

[0142] In a third aspect, an embodiment of the present invention provides a computer-readable medium, on which computer instructions are stored. When the computer instructions are executed by a processor, the processor executes the method provided in the first aspect.

[0143] Specifically, a system or device equipped with a storage medium can be provided, on which software program code that implements the functions of any of the above-mentioned embodiments is stored, and a computer (or CPU or MPU) of the system or device can read and execute the program code stored in the storage medium.

[0144] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.

[0145] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.

[0146] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.

[0147] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion module connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or expansion module is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.

[0148] It is understandable that the explanation, specific implementation methods, beneficial effects, examples, etc. of the relevant contents in the computer-readable medium provided in the embodiment of the present invention can be found in the corresponding parts of the method provided in the first aspect, and will not be repeated here.

[0149] In a fourth aspect, an embodiment of the present specification provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements the method in any embodiment of the specification.

[0150] It is understandable that the explanation, specific implementation, beneficial effects, examples, etc. of the relevant contents in the computing device provided in the embodiment of the present invention can be found in the corresponding parts of the method provided in the first aspect, and will not be repeated here.

[0151] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0152] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the present invention can be implemented by hardware, software, widgets, or any combination thereof. When implemented by software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.

[0153] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for merging table cells, characterized in that: include: Use the field in the table that needs to be merged as the reference field; Taking each row of data in the table as a piece of data, determining the sorting attribute of the piece of data according to the key value of the reference field in each piece of data, and sorting the pieces of data in the table according to the respective sorting attributes of the pieces of data in the table to obtain a sorted list; A recursive function is used to determine the merge parameters of each group of cells to be merged in the reference field in the sorted list; wherein the merge parameters include a starting position and a number of rows spanned; Merge each group of cells according to the merge parameters of the group of cells to be merged.

2. The method according to claim 1, characterized in that Determining the sorting attribute of each piece of data according to the key value of the reference field in the data includes: Convert the key value of each reference field in each data entry in the table into a string of fixed length by padding with zeros; If there are multiple reference fields, the fixed-length strings corresponding to the key values ​​of each reference field in each piece of data are concatenated, and the resulting concatenated string is used as the sorting attribute corresponding to the data; if there are 1 reference fields, the fixed-length strings corresponding to the key values ​​of each reference field in each piece of data are used as the sorting attribute corresponding to the data.

3. The method according to claim 2, characterized in that The step of converting the key value of each reference field in each piece of data in the table into a string of fixed length by filling zeros includes: If the key value of the reference field is a numerical value, zeros are added to the front of the key value of the reference field to obtain data of a fixed length and then converted into a string format.

4. The method according to claim 2, characterized in that: The step of converting the key value of each reference field in each piece of data in the table into a string of fixed length by filling zeros includes: If the key value of the reference field is a numeric value, subtract the key value of the reference field from 10*(n+1) to obtain a first value, pad the front of the first value with zeros, obtain data of a fixed length and convert it into a string format; wherein n is the maximum length of the key value of the reference field in each piece of data.

5. The method according to claim 1, characterized in that The step of using a recursive function to determine the merge parameters of each group of cells to be merged in the reference field in the sorted list includes: S1. Put each reference field into the first array from largest to smallest; S2. define a first object, where the initial value of the first object is empty; S3. Let the initial value of integer i be 1; S4. Execute the following steps S41 to S45 for the i-th data in the sorted list: S41, let the initial value of integer j be 1; S42, taking out the jth reference field from the first array, and checking whether the key value of the jth reference field in the data exists in the first object; S43, if it does not exist, create a new sorting element item in the first object, the sorting element item has two attributes, the two attributes including the starting position of the merged cell and the number of rows spanned; assign the row index of the data to the starting position of the sorting element item, and set the number of rows spanned by the sorting element item to 1; if it exists, increase the number of rows spanned by the sorting element item corresponding to the data by 1; S44, determining whether j is equal to m, where m is the number of reference fields in the first array; S45, if j is less than m, add 1 to j and return to S42; S5. If j is equal to m, determine whether i is equal to the total number of data in the sorted list; if so, exit the process and use the sorting element items in the first object as the merging parameters of the groups of cells that need to be merged; otherwise, set i+1 and repeat S4.

6. The method according to claim 1, characterized in that The step of placing each reference field into the first array from largest to smallest includes: If there is a hierarchical relationship between the reference fields, the reference fields are placed in the first array from large to small according to the hierarchical relationship; if there is no hierarchical relationship between the reference fields, the reference fields are placed in the first array from large to small according to the order of the reference fields in the sorted list.

7. The method according to claim 1, characterized in that The merging process of each group of cells to be merged according to the merging parameters of the group of cells to be merged includes: According to the starting position in each sorting element item, the corresponding cell in the sorted list is determined, and the cross-row attribute of the cell is set to the number of cross-rows in the sorting element item to realize the merging of cells starting from the starting position and downward by the number of cross-rows.

8. A table cell merging device, characterized in that: include: A field determination module is used to use the field in the table that needs to be merged as a reference field; A table sorting module, used to treat each row of data in the table as a piece of data, determine the sorting attribute of the piece of data according to the key value of the reference field in each piece of data, and sort the pieces of data in the table according to their respective sorting attributes to obtain a sorted list; A parameter determination module, used for determining the merging parameters of each group of cells to be merged in the reference field in the sorted list by using a recursive function; wherein the merging parameters include a starting position and a number of rows spanned; The cell merging module is used to merge a group of cells according to the merging parameters of each group of cells to be merged.

9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed in a computer, the computer is caused to execute the method according to any one of claims 1 to 7.

10. A computing device, characterized in that The method comprises a memory and a processor, wherein the memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • System and method for integrating spreadsheets and word processing tables

    CA2800037A1

  • Table summarizing method, device and system

    CN111027294A

  • Method for generating table page and computing equipment

    CN113688617A

  • Data annotation method and device, table information extraction method and device, and electronic equipment

    CN113901216A

  • Dynamic table merging method and device, equipment and storage medium

    CN114065711A