A table processing method, device, equipment and storage medium with grouping
By listening to table events and calculating the index offset between groups, copying, cutting, deleting, pasting and other operations in tables with grouping logic are implemented, and the problem that the existing technology cannot support these operations is solved.
Patent Information
- Application Number
- CN202410932028.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-07-12
AI Technical Summary
The prior art cannot effectively support copying, cutting, deleting, pasting and other operations in non-standard tables with grouping logic.
By listening to the trigger events for the actionable area of the table, determine the copy area and paste the starting cell, and record the area information. Then, the index offsets between different packets are calculated to implement cross-grouping operations of the table.
The functions of copying, cutting, deleting, pasting and other operations in tables with grouping logic are implemented, and the problem that the existing technology cannot support these operations.
Smart Images

Figure CN118709664B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of table data processing, and in particular to a table processing method, device, equipment and storage medium with grouping. Background Art
[0002] Currently, in nursing software, the shift scheduling business needs to quickly copy the weekly shift schedule that has been scheduled. The weekly shift schedule content is displayed in a dynamic non-standard table that can contain groups or a standard table. It needs to support dragging and selecting tables at any position in tables that contain groups or do not contain groups, and copy, cut, delete, and paste operations. However, the existing table operation algorithm only supports standard table type operations, and does not support non-standard table operations with grouping logic. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a table processing method, device, equipment and storage medium with grouping, which can realize cross-group operation of the table by calculating the index offset between different groups. The specific scheme is as follows:
[0004] In a first aspect, the present application discloses a table processing method with grouping, comprising:
[0005] Monitoring a number of trigger events in the operable area of the table, determining a copy area and a paste start cell according to the trigger events, and recording area information corresponding to the copy area;
[0006] Determine a first starting coordinate corresponding to the paste starting cell and a first group identifier corresponding to the current group, and determine a number of first paste cells corresponding to the first group identifier from the current group based on the first starting coordinate, and if the number of cells in the number of first paste cells is less than the total number of cells corresponding to the copy area, determine whether there is a next group;
[0007] If the next group exists, determining a second starting cell corresponding to the column coordinate of the first starting coordinate in the starting row of the next group, and calculating an index offset corresponding to the second starting cell through a target index corresponding to the second starting cell in the copy area;
[0008] Calculate the second starting coordinates corresponding to the second starting cell in the next group based on the index offset, so as to determine a plurality of second pasting cells corresponding to the second group identifier from the next group through the second starting coordinates;
[0009] If the total number of cells of the first paste cells and the second paste cells is equal to the total number of cells corresponding to the copy area, the paste area is determined by the first paste cells and the second paste cells, and the table data corresponding to the copy area is mapped to the paste area according to the area information.
[0010] Optionally, monitoring a plurality of trigger events of the operable area of the table to determine the copy area and the paste start cell according to the plurality of trigger events, and recording area information corresponding to the copy area, includes:
[0011] According to the current device type, the trigger event corresponding to the current device type is monitored. If the current device type is a computer device, the mouse event and the keyboard event are monitored. If the current device type is a mobile device, the touch event is monitored.
[0012] Determine a selected start trigger cell according to a start event in the mouse event or the touch event, and use the start trigger cell as a start trigger object to cache a start trigger position corresponding to the start trigger object;
[0013] Determine a selected cell according to the mouse event or the moving event in the touch event, and add a selected mark to the selected cell;
[0014] Determine the selected end trigger cell according to the end event in the mouse event or the touch event, and judge whether the position of the end trigger cell is in the operable area; if not in the operable area, take the last cell containing the selection mark in the selected cells as the end trigger cell; if in the operable area, take the currently selected cell as the end trigger cell; take the end trigger cell as the end trigger object, and cache the end trigger position corresponding to the end trigger object;
[0015] Determine the copy area according to the start trigger position and the end trigger position, and determine the selected paste start cell;
[0016] Get the group identifier, row index and column index corresponding to all cells in the copy area.
[0017] Optionally, determining a number of first paste cells corresponding to the first group identifier from the current group based on the first starting coordinate, and if the number of cells of the number of first paste cells is less than the total number of cells corresponding to the copy area, determining whether there is a next group includes:
[0018] Performing coordinate addition calculation on the first starting coordinate based on a preset incremental threshold value to determine a number of first pasting cells corresponding to the first grouping identifier;
[0019] Determine whether the number of cells of the first pasted cells is less than the total number of cells corresponding to the copy area, and if the number of cells of the first pasted cells is less than the total number of cells corresponding to the copy area, determine whether there is a next group;
[0020] If the number of cells of the first paste cells is equal to the total number of cells corresponding to the copy area, the first paste cells are used as the paste area, and the table data corresponding to the copy area is mapped to the paste area according to the area information.
[0021] Optionally, determining a second starting cell corresponding to the column coordinate of the first starting coordinate in the starting row of the next group, and calculating an index offset corresponding to the second starting cell by a target index corresponding to the second starting cell in the copy area, includes:
[0022] Determine the second starting cell based on the column coordinates of the first starting cell and the row coordinates corresponding to the starting row of the next group;
[0023] A target index corresponding to the second starting cell in the copy area is determined, and the target index is used as an index offset of the corresponding second grouping identifier.
[0024] Optionally, the calculating, based on the index offset, a second starting coordinate corresponding to the second starting cell in the next group, so as to determine a plurality of second paste cells corresponding to the second group identifier from the next group through the second starting coordinate, includes:
[0025] Determine, based on the target index and the difference between the index offsets, a second starting coordinate of the second starting cell corresponding to the next group;
[0026] The second starting coordinates are calculated incrementally based on the preset incremental threshold to determine a number of second pasting cells corresponding to the second grouping identifier.
[0027] Optionally, mapping the table data corresponding to the copy area to the paste area according to the area information includes:
[0028] Monitor keyboard events among the trigger events, and if a copy event is monitored, cache the region information into a preset copy list;
[0029] If a cut event is detected, the region information is cached in a preset copy list, and the region information is deleted from the copy region;
[0030] If a deletion event is monitored, the region information is cached in a deletion list, and the region information is deleted from the copy region;
[0031] If a paste event is monitored, the data in the copy list should be set to a paste list, and the paste area is assigned a value through the paste list;
[0032] Generate a record of this operation based on a preset data format, and add the record of this operation to a historical data list;
[0033] If a cancellation event is monitored, a cancellation operation is performed based on the current operation record recorded in the historical data list.
[0034] Optionally, the table processing method with grouping further includes:
[0035] If the sum of the number of cells of the first pasted cells and the second pasted cells is less than the total number of cells corresponding to the copy area, and there is no next group, then the area corresponding to the first pasted cells and the second pasted cells is used as the pasting area;
[0036] The table data corresponding to the first paste cells and the second paste cells in the copy area are mapped to the paste area according to the area information.
[0037] In a second aspect, the present application discloses a table processing device with grouping, comprising:
[0038] An information recording module, used for monitoring a number of trigger events of the operable area of the table, determining a copy area and a paste start cell according to the trigger events, and recording area information corresponding to the copy area;
[0039] a first paste cell determination module, configured to determine a first starting coordinate corresponding to the paste start cell and a first group identifier corresponding to the current group, and determine a number of first paste cells corresponding to the first group identifier from the current group based on the first starting coordinate, and if the number of cells in the number of first paste cells is less than the total number of cells corresponding to the copy area, determine whether there is a next group;
[0040] an offset determination module, configured to determine, if the next group exists, a second starting cell corresponding to the column coordinates of the first starting coordinates in the starting row of the next group, and calculate an index offset corresponding to the second starting cell through a target index corresponding to the second starting cell in the copy area;
[0041] A second pasting cell determining module, configured to calculate a second starting coordinate corresponding to the second starting cell in the next group based on the index offset, so as to determine a plurality of second pasting cells corresponding to the second group identifier from the next group through the second starting coordinate;
[0042] A data pasting module is used to determine a paste area through the first paste cells and the second paste cells if the sum of the number of cells in the first paste cells and the second paste cells is equal to the total number of cells corresponding to the copy area, and map the table data corresponding to the copy area to the paste area according to the area information.
[0043] In a third aspect, the present application discloses an electronic device, comprising:
[0044] Memory, used to store computer programs;
[0045] A processor is used to execute the computer program to implement the aforementioned table processing method with grouping.
[0046] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned table processing method with grouping.
[0047] In the present application, firstly, several trigger events of the operable area of the table are monitored to determine the copy area and the paste start cell according to the several trigger events, and the area information corresponding to the copy area is recorded, and then the first starting coordinate corresponding to the paste start cell and the first group identifier corresponding to the current group are determined, and based on the first starting coordinate, several first paste cells corresponding to the first group identifier are determined from the current group. If the number of cells of the several first paste cells is less than the total number of cells corresponding to the copy area, it is determined whether there is a next group. If the next group exists, the second starting cell corresponding to the column coordinate of the first starting coordinate is determined in the starting row of the next group, and the index offset corresponding to the second starting cell is calculated by the target index corresponding to the second starting cell in the copy area. Finally, the second starting coordinate corresponding to the second starting cell in the next group is calculated based on the index offset, so as to determine several second paste cells corresponding to the second group identifier from the next group through the second starting coordinate. If the sum of the number of cells of the several first paste cells and the several second paste cells is equal to the total number of cells corresponding to the copy area, the paste area is determined by the several first paste cells and the several second paste cells, and the table data corresponding to the copy area is mapped to the paste area according to the area information.
[0048] It can be seen that the method of the present application needs to determine the copy area and the paste start cell according to the monitored table event, and determine several first paste cells corresponding to the current group based on the paste start cell. If the next group exists, the second start cell in the next group is determined, and the index offset corresponding to the second start cell is calculated to determine several second paste cells in the next group through the index offset. If the sum of the number of cells of several first paste cells and several second paste cells is equal to the total number of cells in the copy area, the paste area is determined by several first paste cells and several second paste cells, and the table data corresponding to the copy area is mapped to the paste area according to the area information. In this way, the method of the present application can realize cross-group operation of the table by calculating the index offset between different groups. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0050] Figure 1 A flow chart of a table processing method with grouping disclosed in this application;
[0051] Figure 2 A schematic diagram of cross-group pasting disclosed in this application;
[0052] Figure 3 A flow chart of another table processing method with grouping disclosed in this application;
[0053] Figure 4 A schematic diagram of the structure of a table processing device with grouping disclosed in this application;
[0054] Figure 5 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0055] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0056] The prior art lacks a method for performing table operations on non-standardized tables with grouping logic.
[0057] In order to overcome the above technical problems, the present application discloses a table processing method, apparatus, device and storage medium with grouping, which can realize cross-group operation of the table by calculating the index offset between different groups.
[0058] See also Figure 1 As shown, the embodiment of the present invention discloses a table processing method with grouping, including:
[0059] Step S11 , monitoring a number of trigger events in the operable area of the table, determining a copy area and a paste start cell according to the trigger events, and recording area information corresponding to the copy area.
[0060] In this embodiment, it is necessary to monitor the trigger events of the operable area of the table so as to determine the copy area according to the monitored trigger events. It should be noted that it is necessary to monitor the corresponding trigger events according to the device type of the current device. The browser method navigator.userAgent can be used to distinguish the device type to determine whether the current device is a computer device or a mobile device. Then, the jQuery method addEventListener is used to monitor the trigger events, trigger move events, and trigger end events of the document object of the table rendering area, that is, the touchstart, touchmove, and touchend events of the mobile device are monitored, and the mousedown, mousemove, and mouseup events of the computer device are monitored. In addition, the jQuery method addEventListener is also needed to monitor keyboard events (keydown) according to the keyboard ASCII code corresponding to the keyboard Ctrl(17)+C(67), Ctrl(17)+X(83), Ctrl(17)+V(86) and Ctrl+Z(90), Backspace(8), and Delete(46) events.
[0061] It should be noted that after the program obtains the table data, it needs to add label private data attributes when rendering each table in the table's operable area, such as groupId group identifier, rowIndex current group row index, colIndex column index, and recursively process the above private data attributes into the key of "group identifier_current group row index_column index", and store the Object data with row data as the value in tableData. After the data rendering is completed, the left top corner coordinates (startX, startY) and right bottom corner coordinates (endX, endY) of the operation area corresponding to the unique identifier id (selectTable) of the table's operable area need to be cached in tableArea.
[0062] Furthermore, it is necessary to determine the selected starting trigger cell according to the starting event in the mouse event or touch event, and use the starting trigger cell as the starting trigger object to cache the starting trigger position corresponding to the starting trigger object. Specifically, if the mousedown event of the computer device or the touchstart event of the mobile device is monitored, it indicates that the starting trigger cell of the operable area of the table is selected, and then the startInfo and endInof related data previously stored need to be cleared, and then the mouse button monitoring is added to the computer according to the determined device type. When the program determines that it is a left-click trigger, and when the mobile terminal determines that it is a touchstart event, the trigger positions of pageX and pageY of the current triggering document object are cached and recorded, and the group identifier of the groupId of the current triggering object, the rowIndex current group row index, and the colIndex column index are cached and recorded, and all the data currently triggered are stored in the "startInfo" object. It should be further explained that the same method as above can be used to determine the starting cell for pasting in the pasting area.
[0063] Furthermore, the selected cell can be determined according to the movement event in the mouse event or the touch event, and a selection mark can be added to the selected cell. The selected cell in the operable area can be determined according to the monitored mouse movement event mousemove or touch movement event touchmove, and according to the operable area tableArea, the selection style "selectClass" can be added to the current trigger cell in the operation area.
[0064] In the next step, it is necessary to determine the selected end trigger cell according to the mouseup event in the mouse event and the touchend event in the touch event, and determine whether the position of the end trigger cell is in the operable area. If it is not in the operable area, the last cell in the selected cells containing the selected identifier is used as the end trigger cell, that is, according to the unique identifier id (selectTable), the document's find method is used to obtain the last cell whose class value contains "selectClass", and the information of this cell is digitized into "endInfo"; if the currently selected cell is in the operable area, the trigger position of pageX and pageY of the currently triggered document object is cached and recorded, and the group identifier of the current trigger object groupId, rowIndex current group row index, and colIndex column index are cached and recorded, and all the data currently triggered is stored in the "endInfo" object.
[0065] Finally, the end trigger cell needs to be used as the end trigger object, and the copy area needs to be determined based on the start trigger position and the end trigger position. That is, the grid start point (optStartX, optStartY) needs to be generated based on startInfo.pageX and startInfo.pageY, and the grid end point (optEndX, optEndY) needs to be generated based on endInfo.pageX and endInfo.pageY, and the area from the grid start point to the grid end point needs to be used as the copy area.
[0066] Step S12, determining the first starting coordinates corresponding to the paste starting cell and the first group identifier corresponding to the current group, and determining a number of first paste cells corresponding to the first group identifier from the current group based on the first starting coordinates; if the number of cells in the number of first paste cells is less than the total number of cells corresponding to the copy area, determining whether there is a next group.
[0067] In this embodiment, it is necessary to determine the first starting coordinate corresponding to the pasted cell and determine the group identifier of the group where the pasted cell is located, and then determine several first pasted cells in the current group according to the pasted starting cell. Specifically, it is necessary to use a preset table rule and perform coordinate addition calculation on the first starting coordinate based on a preset adding threshold to determine several first pasted cells corresponding to the first group identifier. For example, the first starting coordinate is (optStartX, optStartY). In this embodiment, the preset adding threshold is set to 1, and the coordinates of several first adjacent cells obtained are (optStartX+1, optStartY), (optStartX+2, optStartY) or (optStartX, optStartY+1), (optStartX, optStartY+2), etc.
[0068] Then it is necessary to determine whether the number of cells in the first pasted cell is less than the total number of cells corresponding to the copy area. If the number of cells in the first pasted cell is less than the total number of cells corresponding to the copy area, it indicates that the last row or column has been reached in the group corresponding to the first grouping identifier, but the data in the copy area cannot be completely copied to the pasted cell, so it is necessary to determine whether there is another group.
[0069] Step S13: If the next group exists, determine a second starting cell corresponding to the column coordinates of the first starting coordinates in the starting row of the next group, and calculate the index offset corresponding to the second starting cell through the target index corresponding to the second starting cell in the copy area.
[0070] In this embodiment, if it is determined that there is a next group, it is necessary to determine the second starting cell according to the starting row of the next group and the column coordinate of the first starting coordinate, and then calculate the index offset corresponding to the second starting cell in the next group according to the preset cross-group zeroing rule. It should be noted that the cross-group zeroing rule is as follows: when performing table operations of the cross-group type, when it comes to cross-group situations, the row index (rowIndex) in the cross-group is automatically zeroed. That is, in a selected table of a group, the row indexes of all tables are calculated in an increasing manner. If the group identifier of the current cell: groupId is inconsistent with the group identifier of the previous cell: preGroupId, the index corresponding to the second starting cell in the copy area of the cross-group can be used as the index offset: groupOffset of all rows in this group, and then all rows with (groupId) are retrieved using the array retrieval method and the row index rowIndex of each row is offset to obtain a new row index rowIndex - groupOffset.
[0071] Step S14: Calculate the second starting coordinate corresponding to the second starting cell in the next group based on the index offset, so as to determine a plurality of second paste cells corresponding to the second group identifier from the next group through the second starting coordinate.
[0072] In this embodiment, it is necessary to calculate the second starting coordinate corresponding to the second starting cell in the next group according to the obtained index offset. For example, as Figure 2 shown, in the paste area, "Big Night (Do not move) + 2" is a cross-group cell, and its index corresponding to the copy area is 2, so the obtained index offset is 2. According to the cross-group zeroing rule, its row and column coordinates need to be zeroed, so its coordinates in the new group are (X, 0 + index 2 in the copy area - index offset 2), that is, (X, 0). Therefore, the second starting coordinate corresponding to the second starting cell in the next group is (X, 0). Then, the second starting coordinate can be incremented according to a preset increment threshold to determine a plurality of second paste cells corresponding to the second group identifier. As Figure 2 shown, the coordinates of the adjacent cell "Zheng Test Day Shift 1" in this group can be determined as (X, 1).
[0073] Step S15: If the total number of cells in the plurality of first paste cells and the plurality of second paste cells is equal to the total number of cells corresponding to the copy area, determine the paste area through the plurality of first paste cells and the plurality of second paste cells, and map the table data corresponding to the copy area to the paste area according to the area information.
[0074] In this embodiment, if the total number of cells of the first paste cells and the second paste cells is equal to the total number of cells corresponding to the copy area, it indicates that the copy area can be completely pasted, the area corresponding to the first paste cells and the second paste cells can be determined as the paste area, and the table data corresponding to the first paste cells and the second paste cells in the copy area can be mapped to the paste area according to the preset area mapping rule. It should be noted that the area mapping rule is a two data mapping correspondence rule. The two data are grouped by rows to form two arrays grouped by rows. The lengths of the two arrays are cut according to the smallest length, and finally the two arrays are mapped and corresponded according to the array index.
[0075] It should be further explained that, in some cases, the total number of cells in several first pasted cells and several second pasted cells may be less than the total number of cells corresponding to the copy area, and there is no next grouping. At this time, it is necessary to use the area corresponding to the several first pasted cells and several second pasted cells as the paste area, and then map the table data corresponding to the several first pasted cells and several second paste cells in the copy area to the paste area. At this time, the cells in the copy area that have not been copied to the paste area will no longer be pasted.
[0076] It can be seen that the method of the present application needs to determine the copy area and the paste start cell according to the monitored table event, and determine several first paste cells corresponding to the current group based on the paste start cell. If the next group exists, the second start cell in the next group is determined, and the index offset corresponding to the second start cell is calculated to determine several second paste cells in the next group through the index offset. If the sum of the number of cells of several first paste cells and several second paste cells is equal to the total number of cells in the copy area, the paste area is determined through several first paste cells and several second paste cells, and the table data corresponding to the copy area is mapped to the paste area according to the area information. In this way, the method of the present application can support the positioning and operation of grouped tables in grouped situations through three algorithmic rules: table rules, cross-group zeroing rules, and area mapping rules, so as to realize cross-group operations of tables.
[0077] Based on the above embodiments, it can be seen that through the method of this application, after determining the copy area and the paste area, the data in the copy area needs to be mapped to the paste area, and in addition to the copy and paste operations, table operations such as cut and delete may also be encountered. For this reason, this embodiment describes in detail how to implement table operations. Figure 3 As shown, the embodiment of the present invention discloses a table processing method with grouping, including:
[0078] Step S21: monitor keyboard events among several triggering events, and if a copy event is monitored, cache the region information into a preset copy list.
[0079] In this embodiment, if the keyboard event monitored is a copy event, that is, the ASCII code of the keyboard is Ctrl(17)+C(67), the group identifier groupId, row index rowIndex and column index colIndex values are cached and stored in the copy list copyList, and the operation type is recorded in optType.
[0080] Step S22: If a cut event is detected, the region information is cached in a preset copy list, and the region information is deleted from the copy region.
[0081] In this embodiment, if the keyboard event monitored is a cut event, that is, the ASCII code of the keyboard is Ctrl(17)+X(83), the group identifier groupId, row index rowIndex and column index colIndex values are also cached and stored in the copy list copyList, and the operation type is recorded in optType.
[0082] Step S23: If a deletion event is monitored, the region information is cached in a deletion list, and the region information is deleted from the copy area.
[0083] In this embodiment, if the monitored keyboard event is a delete event, that is, the ASCII code of the keyboard is Backspace (8) or Delete (46), the group identifier groupId, row index rowIndex and column index colIndex values are cached and stored in the delete list deleteList, and the operation type is recorded in optType. A polling loop is used to assemble the key of each value in deleteList according to groupId, rowIndex and colIndex according to "group identifier_current group row index_column index", and delete the data of the corresponding key from tableData.
[0084] Step S24: If a paste event is monitored, the data in the copy list should be set in a paste list, and the paste area is assigned a value through the paste list.
[0085] In this embodiment, if the keyboard event monitored is a delete event, that is, the ASCII code of the keyboard is Ctrl(17)+V(86), it is necessary to cache the groupId, rowIndex and colIndex values and store them in the paste pastList, map the copyList and the pastList accordingly according to the area mapping rule, and use a polling loop to assemble the key of each value in the copyList according to the groupId, rowIndex and colIndex according to "group identifier_current group row index_column index", use the key to obtain the operation data from tableData, obtain the corresponding groupId, rowIndex and colIndex in the pastList according to the area mapping, assemble the key according to "group identifier_current group row index_column index", and assign the value in tableData.
[0086] Furthermore, if optType indicates that the operation type is cut, a polling loop is used to assemble the key of each value in copyList according to groupId, rowIndex and colIndex according to "group identifier_current group row index_column index", delete the data corresponding to the key from tableData, and clear the value in copyList. If it is a copy, this step is not performed.
[0087] Step S25: Generate a record of this operation based on a preset data format, and add the record of this operation to a historical data list.
[0088] In this embodiment, it is necessary to record this operation in the historical data list historyList according to the historical data structure ({optType:'operation type', optKey:'assigned group identifier_current group row index_column index assembly key', oldValue:'original value', newValue:'new value'}), and only record the historical record of opening this module this time.
[0089] Step S26: If a cancellation event is monitored, a cancellation operation is performed based on the current operation record recorded in the historical data list.
[0090] In this embodiment, if the keyboard event monitored is a delete event, that is, the ASCII code of the keyboard is Ctrl(17)+Z(90), the last data is taken from the historyList to restore the deleted or cut data, delete the pasted data, and delete each operation data from the historyList.
[0091] It can be seen that, through the method of the present application, when performing data mapping, it is necessary to perform corresponding operations according to the monitored keyboard events. If a copy event is monitored, the area information is cached in a preset copy list; if a cut event is monitored, the area information is cached in a preset copy list, and the area information is deleted from the copy area; if a delete event is monitored, the area information is cached in a delete list, and the area information is deleted from the copy area; if a paste event is monitored, the data in the copy list should be set in a paste list, and the paste area is assigned a value through the paste list; a record of this operation is generated based on a preset data format, and the record of this operation is added to the historical data list; if an undo event is monitored, an undo operation is performed based on the record of this operation recorded in the historical data list. In this way, non-standard types of tables with grouping types can be copied, pasted, cut, deleted, and withdrawn.
[0092] See also Figure 4 As shown, the embodiment of the present invention discloses a table processing device with grouping, including:
[0093] The information recording module 11 is used to monitor a number of trigger events in the operable area of the table, determine the copy area and the paste start cell according to the trigger events, and record the area information corresponding to the copy area;
[0094] A first paste cell determination module 12 is used to determine a first starting coordinate corresponding to the paste start cell and a first group identifier corresponding to the current group, and determine a number of first paste cells corresponding to the first group identifier from the current group based on the first starting coordinate, and if the number of cells in the number of first paste cells is less than the total number of cells corresponding to the copy area, determine whether there is a next group;
[0095] an offset determination module 13, configured to determine, if the next group exists, a second starting cell corresponding to the column coordinate of the first starting coordinate in the starting row of the next group, and calculate an index offset corresponding to the second starting cell through a target index corresponding to the second starting cell in the copy area;
[0096] A second pasting cell determining module 14 is used to calculate the second starting coordinates corresponding to the second starting cell in the next group based on the index offset, so as to determine a plurality of second pasting cells corresponding to the second group identifier from the next group through the second starting coordinates;
[0097] The data pasting module 15 is used to determine the paste area through the first paste cells and the second paste cells if the sum of the number of cells of the first paste cells and the second paste cells is equal to the total number of cells corresponding to the copy area, and map the table data corresponding to the copy area to the paste area according to the area information.
[0098] In the present application, firstly, several trigger events of the operable area of the table are monitored to determine the copy area and the paste start cell according to the several trigger events, and the area information corresponding to the copy area is recorded, and then the first starting coordinate corresponding to the paste start cell and the first group identifier corresponding to the current group are determined, and based on the first starting coordinate, several first paste cells corresponding to the first group identifier are determined from the current group. If the number of cells of the several first paste cells is less than the total number of cells corresponding to the copy area, it is determined whether there is a next group. If the next group exists, the second starting cell corresponding to the column coordinate of the first starting coordinate is determined in the starting row of the next group, and the index offset corresponding to the second starting cell is calculated by the target index corresponding to the second starting cell in the copy area. Finally, the second starting coordinate corresponding to the second starting cell in the next group is calculated based on the index offset, so as to determine several second paste cells corresponding to the second group identifier from the next group through the second starting coordinate. If the sum of the number of cells of the several first paste cells and the several second paste cells is equal to the total number of cells corresponding to the copy area, the paste area is determined by the several first paste cells and the several second paste cells, and the table data corresponding to the copy area is mapped to the paste area according to the area information. It can be seen that the method of the present application needs to determine the copy area and the paste start cell according to the monitored table event, and determine several first paste cells corresponding to the current group based on the paste start cell. If the next group exists, the second start cell in the next group is determined, and the index offset corresponding to the second start cell is calculated to determine several second paste cells in the next group through the index offset. If the sum of the number of cells of several first paste cells and several second paste cells is equal to the total number of cells in the copy area, the paste area is determined by several first paste cells and several second paste cells, and the table data corresponding to the copy area is mapped to the paste area according to the area information. In this way, the method of the present application can realize cross-group operation of the table by calculating the index offset between different groups.
[0099] In some embodiments, the information recording module 11 may specifically include:
[0100] An event monitoring unit is used to monitor trigger events corresponding to the current device type according to the current device type. If the current device type is a computer device, the mouse events and keyboard events are monitored. If the current device type is a mobile device, the touch events are monitored.
[0101] A first position data cache unit, used to determine a selected start trigger cell according to a start event in the mouse event or the touch event, and use the start trigger cell as a start trigger object to cache a start trigger position corresponding to the start trigger object;
[0102] an identification adding unit, used for determining a selected cell according to the mouse event or the moving event in the touch event, and adding a selection identification to the selected cell;
[0103] A second position data cache unit is used to determine the selected end trigger cell according to the end event in the mouse event or the touch event, and determine whether the position of the end trigger cell is in the operable area. If not in the operable area, the last cell in the selected cells that contains the selection mark is used as the end trigger cell; if in the operable area, the currently selected cell is used as the end trigger cell; the end trigger cell is used as the end trigger object, and the end trigger position corresponding to the end trigger object is cached;
[0104] An area determination unit, used to determine a copy area according to the start trigger position and the end trigger position, and determine a selected paste start cell;
[0105] The data acquisition unit is used to acquire the group identifier, row index and column index corresponding to all cells in the copy area.
[0106] In some embodiments, the first pasting cell determining module 12 may specifically include:
[0107] A first pasting cell determining unit, configured to perform coordinate addition calculation on the first starting coordinate based on a preset adding threshold value, so as to determine a number of first pasting cells corresponding to the first grouping identifier;
[0108] a group existence judgment unit, used to judge whether the number of cells of the first pasted cells is less than the total number of cells corresponding to the copy area, and if the number of cells of the first pasted cells is less than the total number of cells corresponding to the copy area, judge whether there is a next group;
[0109] The first data mapping unit is used to use the first paste cells as the paste area if the number of cells in the first paste cells is equal to the total number of cells corresponding to the copy area, and map the table data corresponding to the copy area to the paste area according to the area information.
[0110] In some embodiments, the offset determination module 13 may specifically include:
[0111] a starting cell determining unit, configured to determine the second starting cell based on the column coordinates of the first starting cell and the row coordinates corresponding to the starting row of the next group;
[0112] The index offset calculation unit is used to determine the target index corresponding to the second starting cell in the copy area, and use the target index as the index offset of the corresponding second grouping identifier.
[0113] In some embodiments, the second pasting cell determining module 14 may specifically include:
[0114] A starting coordinate determining unit, configured to determine a second starting coordinate of the second starting cell corresponding to the next group based on the target index and a difference between the index offsets;
[0115] The second pasting cell determining unit is used to perform coordinate addition calculation on the second starting coordinate based on the preset adding threshold value to determine a number of second pasting cells corresponding to the second grouping identifier.
[0116] In some embodiments, the data pasting module 15 may specifically include:
[0117] A copy event response unit, used for monitoring keyboard events among the trigger events, and if a copy event is monitored, caching the area information into a preset copy list;
[0118] a cut event response unit, configured to cache the region information into a preset copy list and delete the region information from the copy region if a cut event is detected;
[0119] a deletion event response unit, configured to cache the region information in a deletion list and delete the region information from the copy region if a deletion event is monitored;
[0120] A paste event response unit, for setting the data in the copy list to a paste list if a paste event is monitored, and assigning a value to the paste area through the paste list;
[0121] An operation recording unit, used to generate a current operation record based on a preset data format, and add the current operation record to a historical data list;
[0122] The revocation event response unit is used to perform a revocation operation based on the current operation record recorded in the historical data list if a revocation event is monitored.
[0123] In some embodiments, the table processing apparatus with grouping may further include:
[0124] a pasting area determining unit, configured to use the areas corresponding to the first pasting cells and the second pasting cells as the pasting area if the sum of the numbers of cells in the first pasting cells and the second pasting cells is less than the total number of cells corresponding to the copy area and there is no next group;
[0125] The second data mapping unit is used to map the table data corresponding to the first paste cells and the second paste cells in the copy area to the paste area according to the area information.
[0126] Furthermore, the present application also discloses an electronic device. Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0127] Figure 5 The present invention provides a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the table processing method with grouping disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0128] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0129] In addition, the memory 22 as a carrier for resource storage may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage method may be temporary storage or permanent storage.
[0130] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the table processing method with grouping performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0131] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed table processing method with grouping. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, and no further description will be given here.
[0132] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0133] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0134] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0135] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0136] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A table processing method with grouping, characterized in that: include: Monitoring a number of trigger events in the operable area of the table, determining a copy area and a paste start cell according to the trigger events, and recording area information corresponding to the copy area; Determine a first starting coordinate corresponding to the paste starting cell and a first group identifier corresponding to the current group, and determine a number of first paste cells corresponding to the first group identifier from the current group based on the first starting coordinate, and if the number of cells in the number of first paste cells is less than the total number of cells corresponding to the copy area, determine whether there is a next group; If the next group exists, determining a second starting cell corresponding to the column coordinate of the first starting coordinate in the starting row of the next group, and calculating an index offset corresponding to the second starting cell through a target index corresponding to the second starting cell in the copy area; Calculate the second starting coordinates corresponding to the second starting cell in the next group based on the index offset, so as to determine a plurality of second pasting cells corresponding to the second group identifier from the next group through the second starting coordinates; If the sum of the number of cells of the first paste cells and the second paste cells is equal to the total number of cells corresponding to the copy area, a paste area is determined by the first paste cells and the second paste cells, and the table data corresponding to the copy area is mapped to the paste area according to the area information; The determining of a plurality of first pasted cells corresponding to the first group identifier from the current group based on the first starting coordinate, and if the number of cells of the plurality of first pasted cells is less than the total number of cells corresponding to the copy area, determining whether there is a next group includes: Performing coordinate addition calculation on the first starting coordinate based on a preset incremental threshold value to determine a number of first pasting cells corresponding to the first grouping identifier; Determine whether the number of cells of the first pasted cells is less than the total number of cells corresponding to the copy area, and if the number of cells of the first pasted cells is less than the total number of cells corresponding to the copy area, determine whether there is a next group; If the number of cells of the first pasted cells is equal to the total number of cells corresponding to the copy area, the first pasted cells are used as the pasted area, and the table data corresponding to the copy area is mapped to the pasted area according to the area information; The step of determining a second starting cell corresponding to the column coordinate of the first starting coordinate in the starting row of the next group, and calculating the index offset corresponding to the second starting cell by the target index corresponding to the second starting cell in the copy area includes: Determine the second starting cell based on the column coordinates of the first starting coordinates and the row coordinates corresponding to the starting row of the next group; Determine a target index corresponding to the second starting cell in the copy area, and use the target index as an index offset of a corresponding second grouping identifier; The step of calculating the second starting coordinates corresponding to the second starting cell in the next group based on the index offset, so as to determine a plurality of second paste cells corresponding to the second group identifier from the next group through the second starting coordinates, includes: Determine, based on the target index and the difference between the index offsets, a second starting coordinate corresponding to the second starting cell in the next group; The second starting coordinates are calculated incrementally based on the preset incremental threshold to determine a number of second pasting cells corresponding to the second grouping identifier.
2. The table processing method with grouping according to claim 1, characterized in that: The monitoring of several triggering events of the operable area of the table to determine the copy area and the paste start cell according to the several triggering events, and recording the area information corresponding to the copy area, includes: According to the current device type, the trigger event corresponding to the current device type is monitored. If the current device type is a computer device, the mouse event and the keyboard event are monitored. If the current device type is a mobile device, the touch event is monitored. Determine a selected start trigger cell according to a start event in the mouse event or the touch event, and use the start trigger cell as a start trigger object to cache a start trigger position corresponding to the start trigger object; Determine a selected cell according to the mouse event or the moving event in the touch event, and add a selected mark to the selected cell; Determine the selected end trigger cell according to the end event in the mouse event or the touch event, and judge whether the position of the end trigger cell is in the operable area; if not in the operable area, take the last cell containing the selection mark in the selected cells as the end trigger cell; if in the operable area, take the currently selected cell as the end trigger cell; take the end trigger cell as the end trigger object, and cache the end trigger position corresponding to the end trigger object; Determine the copy area according to the start trigger position and the end trigger position, and determine the selected paste start cell; Get the group identifier, row index and column index corresponding to all cells in the copy area.
3. The table processing method with grouping according to claim 2, characterized in that: The mapping the table data corresponding to the copy area to the paste area according to the area information includes: Monitor keyboard events among the trigger events, and if a copy event is monitored, cache the region information into a preset copy list; If a cut event is detected, the region information is cached in a preset copy list, and the region information is deleted from the copy region; If a deletion event is monitored, the region information is cached in a deletion list, and the region information is deleted from the copy region; If a paste event is monitored, the data in the copy list is mapped to the paste list, and the paste area is assigned a value through the paste list; Generate a record of this operation based on a preset data format, and add the record of this operation to a historical data list; If a cancellation event is monitored, a cancellation operation is performed based on the current operation record recorded in the historical data list.
4. The table processing method with grouping according to any one of claims 1 to 3, characterized in that: Also includes: If the sum of the number of cells of the first pasted cells and the second pasted cells is less than the total number of cells corresponding to the copy area, and there is no next group, then the area corresponding to the first pasted cells and the second pasted cells is used as the pasting area; The table data corresponding to the first paste cells and the second paste cells in the copy area are mapped to the paste area according to the area information.
5. A table processing device with grouping, characterized in that: include: An information recording module, used for monitoring a number of trigger events of the operable area of the table, determining a copy area and a paste start cell according to the trigger events, and recording area information corresponding to the copy area; a first paste cell determination module, configured to determine a first starting coordinate corresponding to the paste start cell and a first group identifier corresponding to the current group, and determine a number of first paste cells corresponding to the first group identifier from the current group based on the first starting coordinate, and if the number of cells in the number of first paste cells is less than the total number of cells corresponding to the copy area, determine whether there is a next group; an offset determination module, configured to determine, if the next group exists, a second starting cell corresponding to the column coordinates of the first starting coordinates in the starting row of the next group, and calculate an index offset corresponding to the second starting cell through a target index corresponding to the second starting cell in the copy area; A second pasting cell determining module, configured to calculate a second starting coordinate corresponding to the second starting cell in the next group based on the index offset, so as to determine a plurality of second pasting cells corresponding to a second group identifier from the next group through the second starting coordinate; a data pasting module, configured to determine a pasting area through the first pasting cells and the second pasting cells if the sum of the numbers of cells of the first pasting cells and the second pasting cells is equal to the total number of cells corresponding to the copy area, and map the table data corresponding to the copy area to the pasting area according to the area information; Wherein, the first pasting cell determination module includes: A first pasting cell determining unit, configured to perform coordinate addition calculation on the first starting coordinate based on a preset adding threshold value, so as to determine a number of first pasting cells corresponding to the first grouping identifier; a group existence judgment unit, used to judge whether the number of cells of the first pasted cells is less than the total number of cells corresponding to the copy area, and if the number of cells of the first pasted cells is less than the total number of cells corresponding to the copy area, judge whether there is a next group; a first data mapping unit, configured to use the first pasted cells as a pasting area if the number of cells in the first pasted cells is equal to the total number of cells corresponding to the copy area, and map the table data corresponding to the copy area to the pasting area according to the area information; Wherein, the offset determination module includes: a starting cell determining unit, configured to determine the second starting cell based on the column coordinates of the first starting coordinates and the row coordinates corresponding to the starting row of the next group; An index offset calculation unit, used to determine a target index corresponding to the second starting cell in the copy area, and use the target index as an index offset of a corresponding second grouping identifier; Wherein, the second pasting cell determination module includes: A starting coordinate determining unit, configured to determine a second starting coordinate of the second starting cell corresponding to the next group based on the target index and a difference between the index offsets; The second pasting cell determining unit is used to perform coordinate addition calculation on the second starting coordinate based on the preset adding threshold value to determine a number of second pasting cells corresponding to the second grouping identifier.
6. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the table processing method with grouping as claimed in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the table processing method with grouping as claimed in any one of claims 1 to 4.
Citation Information
Patent Citations
Information display method and device, electronic equipment and storage medium
CN110404252A
Table data filling method and device, electronic equipment and storage medium
CN116050361A