Table cell merging method and apparatus, medium, device

By using recursive functions in tables to automatically calculate cell merging parameters, the problem of redundant duplicate data in traditional tables is solved, efficient and accurate cell merging is achieved, and user experience and data display efficiency are improved.

CN119849455BActive Publication Date: 2025-10-17SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The large amount of repeated data in traditional table data display leads to redundancy, affecting user reading efficiency. Existing technologies make it difficult to efficiently merge cells to simplify the display.

Method used

By using the fields that need to be merged in the table as reference fields, and using recursive functions to determine the cell merging parameters, including the starting position and the number of rows across, the cells can be automatically calculated and merged.

Benefits of technology

It improves the efficiency and accuracy of cell merging, simplifies the workload of developers, improves the aesthetics and readability of tables, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119849455B_ABST
    Figure CN119849455B_ABST
Patent Text Reader

Abstract

The application provides a table cell merging method and device, medium and equipment. The method comprises the following steps: taking a field needing cell merging in a table as a reference field; taking each row data in the table as a piece of data, determining the sorting attribute of the data according to the key value of the reference field in each piece of data, 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 the merging parameter of each group of cells needing merging in the reference field in the sorted list by using a recursive function; wherein the merging parameter comprises a starting position and a cross-row row number; and merging each group of cells needing merging according to the merging parameter of each group of cells. The application can improve the efficiency and accuracy of cell merging, simplify the workload of developers, and improve the aesthetic and readability of the table in the user interface through cell merging.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

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

[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, which is not only redundant but also affects the user's reading efficiency when encountering a large amount of repeated data. Therefore, cell merging is needed. SUMMARY

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

[0004] According to a first aspect, the present application embodiment provides a table cell merging method, which comprises:

[0005] Taking a field in a table that needs to be merged as a 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 the piece of data, and sorting each piece of data in the table according to the sorting attribute of each piece of data to obtain a sorted list;

[0007] Using a recursive function to determine the merging parameter of each group of cells that needs to be merged in the reference field in the sorted list; wherein the merging parameter includes a starting position and a cross-row row number;

[0008] According to the merging parameter of each group of cells that needs to be merged, merging the group of cells.

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

[0010] Converting the key value of each reference field in each piece of data in the table into a fixed-length string through zero padding;

[0011] If the number of reference fields is more than one, the fixed-length strings corresponding to the key values of each reference field in each piece of data are spliced, and the obtained spliced string is taken as the sorting attribute corresponding to the piece of data; if the number of reference fields is one, the fixed-length strings corresponding to the key values of each reference field in each piece of data are taken as the sorting attribute corresponding to the piece of data.

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

[0013] If the key value of the reference field is a numerical value, the key value of the reference field is zero-padded in front to obtain fixed-length data, and then converted into a string format.

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

[0015] If the key value of the reference field is a numerical value, 10*(n+1) is subtracted from the key value of the reference field to obtain a first value, and the first value is zero-padded in front to obtain fixed-length data, 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.

[0016] In one embodiment, the determining the merging parameter of each group of cells in the reference field that needs to be merged in the sorted list by using a recursive function comprises:

[0017] S1, placing each reference field in a first array from large to small;

[0018] S2, defining a first object, and the initial value of the first object is empty;

[0019] S3, setting the initial value of an integer i to 1;

[0020] S4, for the i-th piece of data in the sorted list, performing the following steps S41-S45:

[0021] S41, setting the initial value of an integer j to 1;

[0022] S42, taking the j-th reference field from the first array, and determining whether the key value of the j-th reference field in the data exists in the first object;

[0023] S43, if not, creating a new sorting element item in the first object, the sorting element item having two attributes, the two attributes including the starting position of the merged cell and the number of cross rows; assigning the row index of the data to the starting position of the sorting element item, and setting the number of cross rows of the sorting element item to 1; if yes, increasing the number of cross rows of the sorting element item corresponding to the data by 1;

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

[0025] S45, if j is less than m, then j is added 1, and returns to S42;

[0026] S5, if j is equal to m, then it is judged whether i is equal to the total number of data in the sorted list; if yes, then the process is exited, and each sorting element item in the first object is taken as the merging parameter of each group of cells to be merged; otherwise, i is added 1, and S4 is repeatedly executed.

[0027] In one embodiment, the putting of each reference field from large to small into the first array comprises:

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

[0029] In one embodiment, the merging processing of each group of cells to be merged according to the merging parameter of each group of cells to be merged comprises:

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

[0031] According to the second aspect, the table cell merging device provided by the embodiments of the present application comprises:

[0032] The field determination module is configured to take the field in the table to be merged as a reference field;

[0033] The table sorting module is configured to take 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 the piece of data, and sort 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;

[0034] The parameter determination module is configured to determine the merging parameter of each group of cells to be merged in the reference field in the sorted list by using a recursive function; wherein the merging parameter comprises a starting position and a cross-row number;

[0035] The cell merging module is configured to merge each group of cells to be merged according to the merging parameter of each group of cells to be merged.

[0036] According to a third aspect, an embodiment of the present application provides a computer readable storage medium, having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method according to the first aspect.

[0037] According to a fourth aspect, an embodiment of the present application provides a computing device, comprising a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement the method according to the first aspect.

[0038] The table cell merging method and device, medium and equipment provided by the embodiments of the present application take the field that needs to be merged in the table as a reference field, take each row of data in the table as a piece of data, determine the sorting attribute of each piece of data according to the key value of the reference field in the piece of data, sort each piece of data in the table according to the sorting attribute of each piece of data, obtain a sorted list, determine the starting position and the number of rows of each group of cells that need to be merged in the reference field in the sorted list by using a recursive function, and finally merge each 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 embodiments of the present application, each piece of data in the list is sorted first, so that the same cells in the column corresponding to the reference field are arranged in a continuous manner, and then the starting position and the number of rows of the cells that need to be merged in the arranged list are automatically calculated by using a recursive algorithm, and the cells are merged according to the starting position and the number of rows. The whole process does not need human intervention, can improve the efficiency and accuracy of cell merging, can simplify the workload of the developers, can improve the aesthetic and readability of the table in the user interface through cell merging, can improve the user experience, and is easy to maintain and extend. BRIEF DESCRIPTION OF DRAWINGS

[0039] Figure 1 FIG. 1 is a flowchart of a table cell merging method according to an embodiment of the present application;

[0040] Figure 2 FIG. 2 is a structural block diagram of a table cell merging device according to an embodiment of the present application. DETAILED DESCRIPTION

[0041] In a first aspect, an embodiment of the present application provides a table cell merging method, referring to FIG. 1, Figure 1 The method comprises the following steps S110-S140:

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

[0043] For example, referring to 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 table, i.e., there are 11 pieces of data in total. Since there are several cells in the "province" column of the table that are "Beijing", and several cells that are "Shandong Province", and there are several cells in the "city" column of the table that are "Beijing", several cells that are "Jinan", and several cells that are "Qingdao", the fields of the "province" and "city" columns can be used as reference fields, i.e., the reference fields are "province" and "city".

[0044] Table 1: Table to be merged

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

[0046] S120, each piece of data in the table is taken as a piece of data, the sorting attribute of the piece of data is determined according to the key value of the reference field in the piece of data, and each piece of data in the table is sorted according to the sorting attribute of each piece of data, to obtain a sorted list;

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

[0048] In an embodiment, the determination of the sorting attribute of each piece of data according to the key value of the reference field in the piece of data in S120 can include S121-S122.

[0049] S121, the key value of each reference field in each piece of data in the table is converted into a fixed-length string by zero padding;

[0050] S122, if the number of reference fields is more than one, the fixed-length strings corresponding to the key values of the reference fields in each piece of data are concatenated, and the concatenated string is taken as the sorting attribute corresponding to the piece of data; if the number of reference fields is one, the fixed-length strings corresponding to the key values of the reference fields in each piece of data are taken as the sorting attribute corresponding to the piece of data.

[0051] For example, the reference fields are a, b, and c, the key value Va of the reference field a in each piece of data is the content of the cell, which is a number or a string of numbers, and the subsequent sorting is ascending order. In this case, the key value can be padded with zeros in front to make its length fixed. Specifically, this can be achieved by 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 piece of data in the table into a fixed-length string by zero padding in S121 can include: if the key value of the reference field is a numerical value, then zero padding is performed in front of the key value of the reference field to obtain fixed-length data, and then the data is converted into a string format.

[0053] Of course, if the subsequent sorting is in descending order, a large number can be subtracted first to reverse the size, and then zero padding can be performed to make the length consistent. This can be implemented through the following function: Va' = (10 * (n + 1) - Number(Va)).toString().padStart(n, '0').

[0054] It can be seen that the conversion of the key value of each reference field in each piece of data in the table into a fixed-length string by zero padding in S121 can include: if the key value of the reference field is a numerical value, then zero padding is performed in front of the key value of the reference field to obtain fixed-length data, and then the data is converted into a string format.

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

[0056] Wherein, toString() refers to a function that converts a numerical value to a string.

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

[0058] Wherein, the sorting attribute in S122 can be denoted 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 piece of data in the table, the data can be sorted according to the sortid. The sorting can be implemented through the following function: list.sort((r1, r2) => r1.sortId.localeCompare(r2.sortId)), wherein r1 and r2 are two pieces of data. It can be seen that in the function, the Unicode encoding of the sortid of the two pieces of data is compared according to localeCompare to determine the order of the Unicode encoding, and then the sort function is used for sorting.

[0060] Wherein, localeCompare() is a comparison function.

[0061] wherein sort is a sorting function.

[0062] wherein list is a table to be sorted.

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

[0064] Table 2 after sorting

[0065]

[0066]

[0067] S130, determining, by using a recursive function, a merging parameter of each group of cells to be merged in the reference field in the sorted list; wherein the merging parameter includes a starting position and a number of rows to be crossed;

[0068] That is, for each column corresponding to a reference field, the starting position and the number of rows to be crossed of each cell to be merged need to be determined.

[0069] In an embodiment, the determining, by using a recursive function, a merging parameter of each group of cells to be merged in the reference field in the sorted list in S130 can include S1-S5:

[0070] S1, placing each reference field in a first array from large to small;

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

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

[0073] That is, placing the reference field with a higher level at a front position in the first array, or placing the reference field arranged at the front in the sorted list at a front position in the first array, which helps to execute the recursive function and avoid confusion.

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

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

[0076] S3, set the initial value of integer i as 1;

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

[0078] S4, execute the following steps S41-S45 for the i-th data in the sorted list:

[0079] S41, set the initial value of integer j as 1;

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

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

[0082] S42, take the j-th reference field from the first array, and determine whether the key value of the j-th reference field in the data exists in the first object;

[0083] S43, if not, create a new sorting element item in the first object, the sorting element item has two attributes, which include the starting position of the merged cell and the number of cross rows; assign the row index of the data to the starting position of the sorting element item, and set the number of cross rows of the sorting element item as 1; if yes, increase the number of cross rows of 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, the data is the first row of "province" column in the sorted list, and the data item is "Beijing City" in "province" column, i.e. the data item is "Beijing City" at this time. The key value of the first reference field in the data is "Beijing City", which does not exist in the first object because the first object is empty at this time. At this time, a sorting element item is added in the first object, the starting position attribute of the sorting element item is set as row index 1, and the number of cross rows attribute is set as 1.

[0085] It can be understood that a sorting element item needs to be added at the beginning. When the execution reaches the later rows, the sorting element item may or may not need to be added. 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, and at this time, a sorting element item does not need to be newly created, but the value of the cross-row row number attribute of the corresponding sorting element item in the first object is added by 1.

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

[0087] S45, if j is less than m, then j is added by 1, and the process returns to S42;

[0088] S5, if j is equal to m, then judging whether i is equal to the total number of data in the sorted list; if yes, the process exits, and each sorting element item in the first object is taken as a merging parameter of each group of cells to be merged; otherwise, i is added by 1, and S4 is repeatedly executed.

[0089] It can be seen that for each data, each reference field in the first array needs to be traversed, and then the steps corresponding to the next data are executed. That is, when j is equal to the number of reference fields in the first array, S41-S45 are exited. If i is less than the total number of data in the sorted list at this time, i is added by 1, so that S41-S45 are executed for the next 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 outputted.

[0090] For example, the total number of each sorting element item stored in the first object is 5: the 4 cells with the key value of "Beijing City" in the "province" column need to be merged, so there is a corresponding sorting element item, the 7 cells with the key value of "Shandong Province" need to be merged, so there is a corresponding sorting element item. In the "city" column, the 4 cells with the key value of "Beijing City" need to be merged, so there is a corresponding sorting element item, the 4 cells with the key value of "Jinan City" need to be merged, so there is a corresponding sorting element item, and the 3 cells with the key value of "Qingdao City" need to be merged, so there is a corresponding sorting element item.

[0091] Of course, for the key values of the cells in a column that are different from the key values of other cells, that is, a cell is different from other cells in the column, there is also a sorting element item, but the cross-row row number attribute in the sorting element item is 1, and it can be seen that the cells will not be merged.

[0092] The sorting element item is denoted as sortItem, and includes the following two attributes:

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

[0094] (2) rowspan: represents the number of rows of the merged cell.

[0095] Wherein, the recursive function can be denoted as mergeCell(item, index, obj, category).

[0096] The parameter meanings are as follows:

[0097] item: the ith data in the sorted list;

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

[0099] obj: the first object;

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

[0101] S140, according to the merging parameters of each group of cells that need to be merged, the group of cells is merged.

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

[0103] Table 3: Merged list

[0104]

[0105] In one embodiment, S140, according to the merging parameters of each group of cells that need to be merged, the group of cells is merged, can include:

[0106] According to the starting position in each sorting element item, the corresponding cell in the sorted list is determined, and the row span attribute of the cell is set to the number of rows in the sorting element item, so as to realize the merging of the cells from the starting position and downward by the number of 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 row span attribute of the cell is set to the number of rows in the sorting element item, so that the cell and the (number of rows-1) cells below the cell are merged into one cell, and the content of the merged cell is the content of the cell corresponding to the starting position.

[0108] Wherein, the cross-row attribute of the cell is the rowspan. The rowspan attribute is an object attribute in the HTML language, mainly used for realizing the cross-row function of the cell in the table. When the rowspan attribute is used in the td tag, the number of rows that a cell spans can be specified, thereby realizing the effect of one column spanning multiple rows. The td is an HTML tag, representing a cell in the HTML table.

[0109] Wherein, in determining the need for the starting position in the corresponding cell in the sorted list, the corresponding cell is obtained through the nested sortObj[item.province], sortObj[item.province][item.city]. The reason for adopting such a hierarchical nested way is to avoid data disorder in the case of the same cell in different columns, for example, there is an x city under Beijing city, and there is also an x city under Shandong province. If the data is placed in the same level, the subsequent processing data will be covered, resulting in data disorder.

[0110] The embodiment of the application has the following beneficial effects:

[0111] (1) Improve the efficiency and accuracy of data display: by automatically calculating the position and number of merged cells, avoid human errors that may occur when manually setting the rowspan attribute, and ensure the correct display of table data.

[0112] (2) Enhance user experience: by merging repeated data, reduce visual redundancy of the table, make the table more concise and clear, improve user reading experience.

[0113] (3) Simplify development work: the method provided by the application 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 extend: since the method of the application is based on clear logic and algorithm, subsequent maintenance and function extension become simpler, easy to adapt to different business demand changes, through recursive algorithm, can be conveniently extended to multi-level data merging scene.

[0115] (5) Support flexible data sorting: the application supports multiple data sorting methods, which can meet the display needs in different scenarios.

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

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

[0118] In a second aspect, the embodiments of the present application provide a table cell merging device, referring to Figure 2 The device 100 comprises:

[0119] The field determination module 110 is configured to determine a field in the table as a reference field, which needs to be merged.

[0120] The table sorting module 120 is configured to determine the sorting attribute of each piece of data in the table according to the key value of the reference field in each piece of data, and sort each piece of data in the table according to the sorting attribute of each piece of data, to obtain a sorted list.

[0121] The parameter determination module 130 is configured to determine the merging parameter of each group of cells to be merged in the reference field in the sorted list by using a recursive function; wherein the merging parameter comprises a starting position and a number of rows.

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

[0123] In an embodiment, the table sorting module comprises:

[0124] The pre-zero padding unit is configured to convert the key value of each reference field in each piece of data in the table into a fixed-length string by zero padding.

[0125] The attribute determination unit is configured to, if the number of reference fields is more than one, splice the fixed-length strings corresponding to the key values of the reference fields in each piece of data, and take the spliced string as the sorting attribute corresponding to the piece of data; and if the number of reference fields is one, take the fixed-length string corresponding to the key value of the reference field in each piece of data as the sorting attribute corresponding to the piece of data.

[0126] In an embodiment, the pre-zero padding unit is specifically configured to, if the key value of the reference field is a numerical value, pad zeros in front of the key value of the reference field, and convert the obtained fixed-length data into a string format.

[0127] In one embodiment, the pre-padding unit is specifically configured to: if the key value of the reference field is a numerical value, subtract 10*(n+1) from the key value of the reference field to obtain a first value, pad zeros in front of the first value to obtain data of a fixed length, and then convert 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.

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

[0129] S1, placing each reference field from large to small into a first array;

[0130] S2, defining a first object, and the initial value of the first object is empty;

[0131] S3, setting the initial value of an integer i to 1;

[0132] S4, performing the following steps S41-S45 on the i-th piece of data in the sorted list:

[0133] S41, setting the initial value of an integer j to 1;

[0134] S42, taking the j-th reference field from the first array, and determining whether the key value of the j-th reference field in the data exists in the first object;

[0135] S43, if the key value does not exist in the first object, creating a new sorting element item in the first object, the sorting element item having two attributes, the two attributes including a start position of a merged cell and a cross-row row number; assigning the row index of the data to the start position of the sorting element item, and setting the cross-row row number of the sorting element item to 1; if the key value exists in the first object, increasing the cross-row row number of the sorting element item corresponding to the data by 1;

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

[0137] S45, if j is less than m, setting j to j+1, and returning to S42;

[0138] S5, if j is equal to m, determining whether i is equal to the total number of data in the sorted list; if yes, exiting the flow, and taking each sorting element item in the first object as a merging parameter of each group of cells to be merged; otherwise, setting i to i+1, and repeating S4.

[0139] In one embodiment, the process of arranging the reference fields in the parameter determining module into the first array in descending order includes: if there is a hierarchical relationship between the reference fields, arranging the reference fields in the first array in descending order according to the hierarchical relationship; if there is no hierarchical relationship between the reference fields, arranging the reference fields in the first array in descending order according to the order of the reference fields in the sorted list.

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

[0141] It can be understood that the explanations, specific embodiments, beneficial effects, examples and the like of the device provided in the embodiments of the present application can refer to the corresponding parts in the method provided in the first aspect, and will not be repeated here.

[0142] In a third aspect, the embodiments of the present application provide a computer readable medium, and the computer readable medium stores computer instructions. 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, and the storage medium stores software program codes for implementing the functions of any of the above embodiments, and the computer (or CPU or MPU) of the system or device reads and executes the program codes stored in the storage medium.

[0144] In this case, the program codes read from the storage medium can implement the functions of any of the above embodiments, and therefore the program codes and the storage medium storing the program codes constitute a part of the present application.

[0145] The storage medium for providing the program codes includes 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 codes can be downloaded from a server computer via a communication network.

[0146] In addition, it should be clear that not only the program codes read by the computer can be executed, but also part or all of the actual operations can be completed by the operating system and the like operating on the computer based on the instructions of the program codes, so as to implement the functions of any of the above embodiments.

[0147] Further, it is understood that the programs while being read by the storage media are written into the memory provided in the extension board inserted into the computer or the memory provided in the extension module connected to the computer, and then the CPU or the like mounted on the extension board or the extension module is caused to perform part or all of the actual operation based on the instructions of the program codes, thereby realizing the functions of any of the above-described embodiments.

[0148] It is to be understood that the explanation of the content, the detailed description, the beneficial effects, the examples and the like provided in the computer readable medium of the embodiments of the present application can refer to the corresponding parts in 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, comprising a memory and a processor, wherein the memory stores executable codes, and the processor executes the executable codes to implement the method in any of the embodiments of the present specification.

[0150] It is to be understood that the explanation of the content, the detailed description, the beneficial effects, the examples and the like provided in the computer readable medium of the embodiments of the present application can refer to the corresponding parts in the method provided in the first aspect, and will not be repeated here.

[0151] Each of the embodiments in the present specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each of the embodiments mainly describes the difference from other embodiments. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the part of the description of the method embodiments.

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

[0153] The above detailed description further describes the purpose, technical solutions and beneficial effects of the present application. It should be understood that the above description is only a specific embodiment of the present application, and is not used to limit the protection scope of the present application. Any modification, equivalent replacement, improvement and the like made on the basis of the technical solutions of the present application shall be included in the protection scope of the present application.

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 a 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 attributes of each piece of data in the table to obtain a sorted list; Using a recursive function to determine the merge parameters of each group of cells that need 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; Merging each group of cells according to the merge parameters of the cells to be merged; determining the sorting attribute of each piece of data according to the key value of the reference field in each piece of data, including: Convert the key value of each reference field in each data entry in the table into a fixed-length string 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 is only one reference field, 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; 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 item in the sorted list: S41. Let the initial value of integer j be 1; S42: Take the jth reference field from the first array and check whether the key value of the jth reference field in the data exists in the first object; S43. If the data item does not exist, create a new sorting element item in the first object, the sorting element item having 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 item to the starting position of the sorting element item, and set the number of rows spanned of the sorting element item to 1; if the data item does exist, increase the number of rows spanned of the sorting element item corresponding to the data item by 1; S44. Determine 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 merge parameters of the groups of cells that need to be merged; otherwise, set i+1 and repeat S4.

2. The method according to claim 1, characterized in that The step of converting the key value of each reference field in each piece of data in the table into a fixed-length character string by padding with 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.

3. The method according to claim 1, characterized in that The step of converting the key value of each reference field in each piece of data in the table into a fixed-length character string by padding with 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.

4. The method according to claim 1, wherein Put each reference field into the first array from largest to smallest, including: 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.

5. The method according to claim 1, wherein 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 of each sorting element item, a corresponding cell in the sorted list is determined, and the spanning attribute of the cell is set to the number of spanning rows in the sorting element item.

6. 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 5.

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

Citation Information

Patent Citations

  • System and method for integrating spreadsheets and word processing tables

    CA2800037A1

  • Table summarizing method, device and system

    CN111027294A