Movatterモバイル変換


[0]ホーム

URL:


CN109213978B - Method and device for merging cells, electronic equipment and readable storage medium - Google Patents

Method and device for merging cells, electronic equipment and readable storage medium
Download PDF

Info

Publication number
CN109213978B
CN109213978BCN201710533329.8ACN201710533329ACN109213978BCN 109213978 BCN109213978 BCN 109213978BCN 201710533329 ACN201710533329 ACN 201710533329ACN 109213978 BCN109213978 BCN 109213978B
Authority
CN
China
Prior art keywords
cell
merged
cells
column
row
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710533329.8A
Other languages
Chinese (zh)
Other versions
CN109213978A (en
Inventor
陈波
皮霞林
项林建
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Guangzhou Kingsoft Mobile Technology Co Ltd
Original Assignee
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Guangzhou Kingsoft Mobile Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Office Software Inc, Zhuhai Kingsoft Office Software Co Ltd, Guangzhou Kingsoft Mobile Technology Co LtdfiledCriticalBeijing Kingsoft Office Software Inc
Priority to CN201710533329.8ApriorityCriticalpatent/CN109213978B/en
Publication of CN109213978ApublicationCriticalpatent/CN109213978A/en
Application grantedgrantedCritical
Publication of CN109213978BpublicationCriticalpatent/CN109213978B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

The embodiment of the invention provides a method and a device for merging cells, electronic equipment and a readable storage medium, wherein the method comprises the following steps: determining the row to be merged or the column to be merged in the data table to be processed, in the row to be merged or the row to be merged, determining a first cell with non-empty content as a 1 st reference cell, determining a target cell meeting a first preset condition as an nth reference cell, merging cells from the nth-1 st reference cell to cells before the nth reference cell into an nth-1 merging cell, merging cells from the nth reference cell to cells before a termination cell into an nth merging cell to obtain a processed data table, the method, the device, the electronic equipment and the readable storage medium for merging the cells provided by the embodiment of the invention can reduce the manual merging operation, save the labor cost and improve the efficiency of the cell merging operation, when the cells with empty contents exist in the row to be merged or the row to be merged, the cells can be correctly merged.

Description

Translated fromChinese
一种合并单元格的方法、装置、电子设备及可读存储介质A method, apparatus, electronic device and readable storage medium for merging cells

技术领域technical field

本发明涉及数据处理技术领域,特别是涉及一种合并单元格的方法、装置、电子设备及可读存储介质。The present invention relates to the technical field of data processing, and in particular, to a method, apparatus, electronic device and readable storage medium for merging cells.

背景技术Background technique

随着计算机技术的发展,计算机在人们的工作、生活中越来越普及。以往通过纸质的方式记录、管理数据的方式也逐渐被计算机代替。With the development of computer technology, computers are becoming more and more popular in people's work and life. In the past, the way of recording and managing data by means of paper has gradually been replaced by computers.

在人们使用计算机中的电子表格软件管理数据的时候,可以将数据输入或导入电子表格软件中,其中,每条数据可以以行或列的方式存储到电子表格软件中。为了方便归类查看,用户往往会对内容相同的单元格进行合并处理。When people use spreadsheet software in a computer to manage data, data can be input or imported into the spreadsheet software, wherein each piece of data can be stored in the spreadsheet software in a row or a column. In order to facilitate classification and viewing, users often merge cells with the same content.

但是,现有技术中,对电子表格中的单元格进行合并时,需要人工对单元格进行合并处理,在数据量大的情况下,人工合并的操作就会比较繁琐。However, in the prior art, when merging cells in a spreadsheet, it is necessary to manually merge the cells. In the case of a large amount of data, the manual merging operation will be cumbersome.

发明内容SUMMARY OF THE INVENTION

本发明实施例的目的在于提供一种合并单元格的方法、装置、电子设备及可读存储介质,以实现减少人工合并的操作,节省人力成本。具体技术方案如下:The purpose of the embodiments of the present invention is to provide a method, apparatus, electronic device, and readable storage medium for merging cells, so as to reduce manual merging operations and save labor costs. The specific technical solutions are as follows:

第一方面,本发明实施例提供了一种合并单元格的方法,所述方法包括:In a first aspect, an embodiment of the present invention provides a method for merging cells, the method comprising:

确定待处理数据表中的待合并行或待合并列,其中,待合并行或待合并列中包括至少两个内容相同且相连的单元格,或,待合并行或待合并列中包括至少一个内容为空的单元格;Determine the rows or columns to be merged in the data table to be merged, wherein the rows or columns to be merged include at least two cells with the same content and are connected, or, the rows or columns to be merged include at least one cell whose content is empty ;

在待合并行或待合并列中,将第一个内容不为空的单元格确定为第1基准单元格,将满足第一预设条件的目标单元格确定为第n基准单元格,其中,第一预设条件为目标单元格内容不为空、与前一单元格内容不同且与第n-1基准单元格内容不同,n为大于1的自然数,目标单元格为待合并行或待合并列中第n-1基准单元格之后的单元格;In the row or column to be merged, the first cell whose content is not empty is determined as the first reference cell, and the target cell that satisfies the first preset condition is determined as the nth reference cell, wherein the first The preset condition is that the content of the target cell is not empty, different from the content of the previous cell, and different from the content of the n-1th reference cell, n is a natural number greater than 1, and the target cell is the nth row or column to be merged. -1 the cell after the base cell;

将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,得到处理后的数据表,其中,终止单元格为在待合并行中第n基准单元格之后,所在列内容都为空的单元格,或者,在待合并列中第n基准单元格之后,所在行内容都为空的单元格。Merge the n-1th reference cell to the cells before the nth reference cell into the n-1th merged cell, and merge the nth reference cell to the cells before the termination cell into the nth merged cell, Obtain the processed data table, where the terminating cell is the cell whose column content is empty after the nth reference cell in the row to be merged, or the content of the row after the nth reference cell in the column to be merged All empty cells.

可选的,确定待处理数据表中的待合并行或待合并列,包括:Optionally, determine the rows or columns to be merged in the data table to be processed, including:

将待处理数据表中满足第二预设条件的行确定为待合并行,或者,将待处理数据表中满足第二预设条件的列确定为待合并列,其中,第二预设条件为在待处理数据表中的同一行或同一列中存在至少两个内容相同且相连的单元格,或,在待处理数据表中的同一行或同一列中存在至少一个内容为空的单元格。Determining a row that satisfies the second preset condition in the data table to be processed is a row to be merged, or, determining a column that satisfies the second preset condition in the data table to be processed as a column to be merged, wherein the second preset condition is the row to be merged. There are at least two cells with the same content and connected in the same row or column in the data table to be processed, or at least one cell with empty content in the same row or column in the data table to be processed.

可选的,在将待处理数据表中满足第二预设条件的行确定为待合并行,或者,将待处理数据表中满足第二预设条件的列确定为待合并列之后,本发明实施例的一种合并单元格的方法,还包括:Optionally, after determining the row in the data table to be processed that meets the second preset condition as the row to be merged, or after determining the column in the data table to be processed that meets the second preset condition as the column to be merged, the embodiment of the present invention A method of merging cells that also includes:

在待处理数据表中存在两个以上待合并行或待合并列时,发送携带有待合并行或待合并列的标识信息的待确认请求至用户;When there are more than two rows or columns to be merged in the data table to be merged, send a pending confirmation request carrying the identification information of the rows or columns to be merged to the user;

获取并根据用户反馈的携带有待合并行或待合并列的标识信息的确认信息,确定待处理数据表中的待合并行或待合并列为包含标识信息的待合并行或待合并列。Acquire and determine the row or column to be merged in the data table to be merged that contains the identification information according to the confirmation information fed back by the user carrying the identification information of the row to be merged or the column to be merged.

可选的,将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,包括:Optionally, merge the n-1th reference cell to the cells before the nth reference cell into the n-1th merged cell, and merge the nth reference cell to the cells before the termination cell into the nth Merge cells, including:

在第n-1基准单元格至第n基准单元格之前的单元格中存在属性不同的单元格时,将第n-1基准单元格至第n基准单元格之前的单元格中任一内容不为空的单元格的属性作为第n-1合并单元格的基准属性,将第n-1基准单元格至第n基准单元格之前的单元格的内容合并为第n-1合并单元格的内容,将第n-1基准单元格至第n基准单元格之前的单元格的属性合并为第n-1合并单元格的基准属性;When there are cells with different attributes in the cells before the n-1th reference cell to the nth reference cell, any content in the cells before the n-1th reference cell to the nth reference cell is not changed. The attribute of the empty cell is used as the base attribute of the n-1th merged cell, and the contents of the cells before the n-1th base cell to the nth base cell are merged into the content of the n-1th merged cell , merge the attributes of the n-1th reference cell to the cells before the nth reference cell into the reference attributes of the n-1th merged cell;

在第n基准单元格至终止单元格之前的单元格中存在属性不同的单元格时,将第n基准单元格至终止单元格之前的单元格中任一内容不为空的单元格的属性确定为第n合并单元格的基准属性,将第n基准单元格至终止单元格之前的单元格的内容合并为第n合并单元格的内容,将第n基准单元格至终止单元格之前的单元格的属性合并为第n合并单元格的基准属性。When there are cells with different attributes in the cells before the nth reference cell to the end cell, determine the attribute of any cell whose content is not empty among the cells from the nth reference cell to the end cell For the base attribute of the nth merged cell, merge the contents of the nth base cell to the cell before the end cell into the content of the nth merged cell, and merge the nth base cell to the cell before the end cell The attributes of are merged into the base attribute of the nth merged cell.

可选的,该属性包括以下至少之一或其组合:字体、对齐方式、缩进间距、样式、单元格格式。Optionally, the attribute includes at least one or a combination of the following: font, alignment, indentation, style, and cell format.

第二方面,本发明实施例还提供了一种合并单元格的装置,所述装置包括:In a second aspect, an embodiment of the present invention further provides an apparatus for merging cells, the apparatus comprising:

行列确定模块,用于确定待处理数据表中的待合并行或待合并列,其中,待合并行或待合并列中包括至少两个内容相同且相连的单元格,或,待合并行或待合并列中包括至少一个内容为空的单元格;The row and column determination module is used to determine the row or column to be merged in the data table to be processed, wherein the row to be merged or the column to be merged includes at least two cells with the same content and connected, or the row to be merged or the column to be merged includes at least one cells with empty content;

基准单元格确定模块,用于在待合并行或待合并列中,将第一个内容不为空的单元格确定为第1基准单元格,将满足第一预设条件的目标单元格确定为第n基准单元格,其中,第一预设条件为目标单元格内容不为空、与前一单元格内容不同且与第n-1基准单元格内容不同,n为大于1的自然数,目标单元格为待合并行或待合并列中第n-1基准单元格之后的单元格;The reference cell determination module is used to determine, in the row or column to be merged, the first cell whose content is not empty as the first reference cell, and the target cell that satisfies the first preset condition as the nth cell The reference cell, wherein the first preset condition is that the content of the target cell is not empty, different from the content of the previous cell, and different from the content of the n-1th reference cell, n is a natural number greater than 1, and the target cell is The cell after the n-1th base cell in the row or column to be merged;

合并模块,用于将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,得到处理后的数据表,其中,终止单元格为在待合并行中第n基准单元格之后,所在列内容都为空的单元格,或者,在待合并列中第n基准单元格之后,所在行内容都为空的单元格。The merge module is used to merge the cells from the n-1th reference cell to the n-th reference cell into the n-1th merged cell, and merge the cells from the nth reference cell to the end cell into the th Merge cells to obtain a processed data table, where the terminating cell is the cell whose column content is empty after the nth reference cell in the row to be merged, or the nth reference cell in the column to be merged After that, the contents of the row are all empty cells.

可选的,行列确定模块,具体用于:Optionally, the row and column determination module, which is specifically used for:

将待处理数据表中满足第二预设条件的行确定为待合并行,或者,将待处理数据表中满足第二预设条件的列确定为待合并列,其中,第二预设条件为在待处理数据表中的同一行或同一列中存在至少两个内容相同且相连的单元格,或,在待处理数据表中的同一行或同一列中存在至少一个内容为空的单元格。Determining a row that satisfies the second preset condition in the data table to be processed is a row to be merged, or, determining a column that satisfies the second preset condition in the data table to be processed as a column to be merged, wherein the second preset condition is the row to be merged. There are at least two cells with the same content and connected in the same row or column in the data table to be processed, or at least one cell with empty content in the same row or column in the data table to be processed.

可选的,本发明实施例的一种合并单元格的装置,还包括:Optionally, a device for merging cells according to an embodiment of the present invention further includes:

发送模块,用于在待处理数据表中存在两个以上待合并行或待合并列时,发送携带有待合并行或待合并列的标识信息的待确认请求至用户;A sending module, configured to send a pending confirmation request carrying the identification information of the rows or columns to be merged to the user when there are more than two rows or columns to be merged in the data table to be merged;

获取模块,用于获取并根据用户反馈的携带有待合并行或待合并列的标识信息的确认信息,确定待处理数据表中的待合并行或待合并列为包含标识信息的待合并行或待合并列。The obtaining module is used for obtaining and according to the confirmation information fed back by the user carrying the identification information of the row or column to be merged, to determine the row to be merged or the column to be merged in the to-be-processed data table that contains the identification information.

可选的,合并模块,具体用于:Optional, merge modules, specifically for:

在第n-1基准单元格至第n基准单元格之前的单元格中存在属性不同的单元格时,将第n-1基准单元格至第n基准单元格之前的单元格中任一内容不为空的单元格的属性作为第n-1合并单元格的基准属性,将第n-1基准单元格至第n基准单元格之前的单元格的内容合并为第n-1合并单元格的内容,将第n-1基准单元格至第n基准单元格之前的单元格的属性合并为第n-1合并单元格的基准属性;When there are cells with different attributes in the cells before the n-1th reference cell to the nth reference cell, any content in the cells before the n-1th reference cell to the nth reference cell is not changed. The attribute of the empty cell is used as the base attribute of the n-1th merged cell, and the contents of the cells before the n-1th base cell to the nth base cell are merged into the content of the n-1th merged cell , merge the attributes of the n-1th reference cell to the cells before the nth reference cell into the reference attributes of the n-1th merged cell;

在第n基准单元格至终止单元格之前的单元格中存在属性不同的单元格时,将第n基准单元格至终止单元格之前的单元格中任一内容不为空的单元格的属性确定为第n合并单元格的基准属性,将第n基准单元格至终止单元格之前的单元格的内容合并为第n合并单元格的内容,将第n基准单元格至终止单元格之前的单元格的属性合并为第n合并单元格的基准属性。When there are cells with different attributes in the cells before the nth reference cell to the end cell, determine the attribute of any cell whose content is not empty among the cells from the nth reference cell to the end cell For the base attribute of the nth merged cell, merge the contents of the nth base cell to the cell before the end cell into the content of the nth merged cell, and merge the nth base cell to the cell before the end cell The attributes of are merged into the base attribute of the nth merged cell.

可选的,该属性包括以下至少之一或其组合:字体、对齐方式、缩进间距、样式、单元格格式。Optionally, the attribute includes at least one or a combination of the following: font, alignment, indentation, style, and cell format.

第三方面,本发明实施例还提供了一种电子设备,包括:处理器、通信接口、存储器和通信总线,其中,处理器、通信接口、存储器通过通信总线完成相互间的通信;In a third aspect, an embodiment of the present invention further provides an electronic device, including: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

存储器,用于存储计算机程序;memory for storing computer programs;

处理器,用于执行存储器上所存储的程序时,实现本发明实施例的第一方面提供的方法步骤;a processor, configured to implement the method steps provided by the first aspect of the embodiments of the present invention when executing the program stored in the memory;

通信接口,用于电子设备与外部设备进行数据交换。Communication interface for data exchange between electronic equipment and external equipment.

第四方面,本发明实施例还提供了一种计算机可读存储介质,计算机可读存储介质内存储有计算机程序,计算机程序被处理器执行时实现本发明实施例的第一方面提供的方法步骤。In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method steps provided in the first aspect of the embodiment of the present invention are implemented .

本发明实施例提供的一种合并单元格的方法、装置、电子设备及可读存储介质,通过确定待处理数据表中的待合并行或待合并列,再确定基准单元格,然后将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,可以减少人工合并的操作,节省人力成本,并且,在待合并行或待合并列中存在内容为空的单元格时,能够实现正确合并单元格。当然,实施本发明的任一产品或方法并不一定需要同时达到以上所述的所有优点。A method, device, electronic device, and readable storage medium for merging cells provided by the embodiments of the present invention, by determining the row or column to be merged in the data table to be processed, and then the reference cell is determined, and then the n-1 The cells from the base cell to the nth base cell are merged into the n-1th merged cell, and the cells from the nth base cell to the end cell are merged into the nth merged cell, which can reduce the number of manual merges. operation, saving labor costs, and when there are cells with empty content in the rows or columns to be merged, the cells can be merged correctly. Of course, it is not necessary for any product or method of the present invention to achieve all of the advantages described above at the same time.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.

图1为本发明实施例的一种合并单元格的方法的第一种实施方式的流程图;1 is a flowchart of a first implementation manner of a method for merging cells according to an embodiment of the present invention;

图2为本发明实施例的一种合并单元格的方法的第二种实施方式的流程图;2 is a flowchart of a second implementation manner of a method for merging cells according to an embodiment of the present invention;

图3为本发明实施例的一种合并单元格的装置的结构示意图;3 is a schematic structural diagram of a device for merging cells according to an embodiment of the present invention;

图4为本发明实施例的一种合并单元格的方法应用于电子设备的结构示意图。FIG. 4 is a schematic structural diagram of a method for merging cells applied to an electronic device according to an embodiment of the present invention.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

为了解决现有技术存在的问题,本发明实施例提供了一种合并单元格的方法、装置、电子设备及可读存储介质,以减少人工合并的操作,节省人力成本。In order to solve the problems existing in the prior art, embodiments of the present invention provide a method, apparatus, electronic device, and readable storage medium for merging cells, so as to reduce manual merging operations and save labor costs.

下面,对本发明实施例的一种合并单元格的方法进行介绍,如图1所示,为本发明实施例的一种合并单元格的方法的第一种实施方式的流程图,该方法可以包括:Next, a method for merging cells according to an embodiment of the present invention is introduced. As shown in FIG. 1 , it is a flowchart of a first implementation manner of a method for merging cells according to an embodiment of the present invention. The method may include: :

S101,确定待处理数据表中的待合并行或待合并列。S101: Determine the row or column to be merged in the data table to be processed.

其中,待合并行或待合并列中包括至少两个内容相同且相连的单元格,或,待合并行或待合并列中包括至少一个内容为空的单元格。该待处理数据表可以是办公软件中的电子表格。Wherein, the row to be merged or the column to be merged includes at least two cells with the same content and connected, or the row to be merged or the column to be merged includes at least one cell whose content is empty. The table of data to be processed may be a spreadsheet in office software.

在待处理数据表中的同一行或同一列中往往会存在相同内容的单元格,也会存在内容为空的单元格,为了方便归类查看,用户可以对同一行或同一列中的单元格进行合并处理,因此,这里可以首先确定待处理数据表中的待合并行或待合并列。There are often cells with the same content in the same row or column in the data table to be processed, and there are also cells with empty content. In order to facilitate classification and viewing, users can Merge processing is performed, therefore, the row to be merged or the column to be merged in the data table to be processed can be determined first.

但是,同一行或同一列中存在相同内容的单元格并不一定是待合并行或待合并列,为了保证本发明实施例的合并单元格的装置能够正确确定待合并行或待合并列。本步骤中的待合并行或待合并列可以包括至少两个内容相同且相连的单元格,或,待合并行或待合并列中包括至少一个内容为空的单元格。However, cells with the same content in the same row or column are not necessarily the rows or columns to be merged, in order to ensure that the device for merging cells in the embodiment of the present invention can correctly determine the rows or columns to be merged. The row to be merged or the column to be merged in this step may include at least two connected cells with the same content, or the row or column to be merged includes at least one cell whose content is empty.

在应用本发明实施例的一种合并单元格的方法合并单元格时,可以按照待处理数据表中的行进行合并,也可以按照待处理数据表中的列进行合并,因此,这里,可以首先确定待处理数据表中的待合并行或待合并列。When applying the method for merging cells according to the embodiment of the present invention, the cells can be merged according to the rows in the data table to be processed, or the columns in the data table to be processed can be merged. Therefore, here, you can first Identify the rows or columns to be merged in the table of data to be processed.

具体的,可以根据用户输入的待合并行或待合并列的标识信息确定待处理数据表中的待合并行或待合并列,也可以通过对待处理数据表中的每行或每列进行分析确定待合并行或待合并列。Specifically, the row to be merged or the column to be merged in the data table to be merged can be determined according to the identification information of the row to be merged or the column to be merged entered by the user, or the row to be merged or the column to be merged can be determined by analyzing each row or column in the data table to be processed. side by side.

应当理解的是,本发明实施例中的待合并行可以是至少一行,待合并列可以是至少一列。It should be understood that, in this embodiment of the present invention, the row to be merged may be at least one row, and the column to be merged may be at least one column.

为了更清楚的说明本发明实施例提供的一种合并单元格的方法,下面举例进行说明。In order to more clearly illustrate a method for merging cells provided by an embodiment of the present invention, an example is described below.

假设,待处理数据表为办公软件中的电子表格,该电子表格中可以预先设置有“行合并”、“列合并”、“合并单元格”三个按钮,该三个按钮可以分别对应三种不同的指令,用户可以点击该三个按钮中的任何一个按钮。Assuming that the data table to be processed is a spreadsheet in office software, the spreadsheet can be preset with three buttons of "row merge", "column merge" and "merge cell", and the three buttons can correspond to three types of buttons respectively. Depending on the instruction, the user can click any one of the three buttons.

例如,用户可以选定要合并的行,然后点击“合并行”的按钮,本发明实施例的合并单元格的装置可以接收到与“合并行”按钮对应的携带有选定的要合并的行的标识信息的指令,从而确定待合并的行;For example, a user may select a row to be merged, and then click a button of "merge rows", the apparatus for merging cells in the embodiment of the present invention may receive a row corresponding to the "merge row" button that carries the selected row to be merged The instruction of the identification information, thereby determining the lines to be merged;

也可以直接点击“合并行”的按钮,本发明实施例的合并单元格的装置可以在接收到与“合并行”按钮对应的合并行的指令后,可以对该电子表格的行进行分析,得到可以进行合并的行,然后发送携带有可以进行合并的行的标识信息的待确认请求给用户,用户可以输入要进行合并的行的标识信息,也可以选定要进行合并的行,本发明实施例的合并单元格的装置可以根据用户输入的标识信息或选定的行确定待合并的行。It is also possible to directly click the button of "merge rows". The device for merging cells according to the embodiment of the present invention can analyze the rows of the spreadsheet after receiving the instruction for merging rows corresponding to the "merge rows" button, and obtain Rows that can be merged, and then send a pending confirmation request carrying the identification information of the rows that can be merged to the user, the user can input the identification information of the rows to be merged, and can also select the rows to be merged. The implementation of the present invention The apparatus for merging cells in the example may determine the row to be merged according to the identification information input by the user or the selected row.

又例如,用户也可以选定要合并的列,然后点击“合并列”的按钮,本发明实施例的合并单元格的装置可以接收到与“合并列”按钮对应的携带有选定的要合并的列的标识信息的指令,从而确定待合并的列;For another example, the user can also select the column to be merged, and then click the button of "merge column", the apparatus for merging cells according to the embodiment of the present invention can receive a message corresponding to the "merge column" button that carries the selected column to be merged. The instruction of the identification information of the column, thereby determining the column to be merged;

也可以直接点击“合并列”的按钮,本发明实施例的合并单元格的装置可以在接收到与“合并列”按钮对应的合并列的指令后,可以对该电子表格的列进行分析,得到可以进行合并的列,然后发送携带有可以进行合并的列的标识信息的待确认请求给用户,用户可以输入要进行合并的列的标识信息,也可以选定要进行合并的列,本发明实施例的合并单元格的装置可以根据用户输入的标识信息或选定的列确定待合并的列。It is also possible to directly click the button of "merge columns". The device for merging cells according to the embodiment of the present invention may, after receiving an instruction to merge columns corresponding to the "merge columns" button, analyze the columns of the spreadsheet to obtain Columns that can be merged, and then send a pending confirmation request carrying the identification information of the columns that can be merged to the user, the user can input the identification information of the columns to be merged, or can select the columns to be merged, the present invention implements The apparatus for merging cells in the example may determine the column to be merged according to the identification information input by the user or the selected column.

用户还可以直接点击“合并单元格”的按钮,本发明实施例的合并单元格的装置可以在接收到与“合并单元格”的按钮对应的合并单元格的指令后,对待处理数据表中的行和列分别进行分析,确定待合并行或待合并列。The user can also directly click the button of "merge cells", and the device for merging cells in the embodiment of the present invention can, after receiving the instruction of merging cells corresponding to the button of "merge cells", process the data in the data table to be processed. Rows and columns are analyzed separately to determine the rows or columns to be merged.

通过确定待处理数据表中的待合并行或待合并列,在本发明实施例的后续步骤中,可以仅对待合并行或待合并列进行处理,不对待处理数据表中的其他行或列进行处理,可以降低合并单元格所消耗的时间,并且,能够降低对硬件设备的内存的占用,提高处理速度。By determining the rows or columns to be merged in the data table to be processed, in the subsequent steps of this embodiment of the present invention, only the rows or columns to be merged may be processed, and other rows or columns in the data table to be processed may not be processed. The time consumed for merging cells is reduced, and the memory occupation of the hardware device can be reduced, and the processing speed can be improved.

S102,在待合并行或待合并列中,将第一个内容不为空的单元格确定为第1基准单元格,将满足第一预设条件的目标单元格确定为第n基准单元格。S102 , in the row or column to be merged, determine the first cell whose content is not empty as the first reference cell, and determine the target cell that satisfies the first preset condition as the nth reference cell.

其中,第一预设条件为目标单元格内容不为空、与前一单元格内容不同且与第n-1基准单元格内容不同,n为大于1的自然数,目标单元格为待合并行或待合并列中第n-1基准单元格之后的单元格。Among them, the first preset condition is that the content of the target cell is not empty, is different from the content of the previous cell, and is different from the content of the n-1th reference cell, n is a natural number greater than 1, and the target cell is the row to be merged or to be merged. The cell after the n-1th base cell in the tie.

这里,基准单元格用于在后续步骤中,对待合并行或待合并列中的单元格进行合并时,提供合并基准,使待合并行或待合并列中的单元格能够正确合并。Here, the reference cell is used to provide a merge reference when cells in the row or column to be merged are merged in a subsequent step, so that the cells in the row or column to be merged can be merged correctly.

在待处理数据表中,处于同一行或同一列的单元格可以包含相同内容的单元格,也可以包含不同内容的单元格,还可以包含内容为空的单元格。但是,将相同内容的单元格进行合并可能会出现错误,因此,为了保证对待合并列或待合并行中的单元格进行正确的合并处理,可以通过本步骤确定待合并行或待合并列中的基准单元格。In the data table to be processed, cells in the same row or column can contain cells with the same content, cells with different content, or cells with empty content. However, errors may occur when merging cells with the same content. Therefore, in order to ensure that the cells in the columns or rows to be merged are correctly merged, you can use this step to determine the reference cells in the rows or columns to be merged. .

在通过上述步骤确定待合并行或待合并列后,在对待合并行或待合并列中的单元格进行合并时,可以首先确定基准单元格,在后续的步骤中可以以基准单元格为基准对待合并行或待合并列中的单元格进行合并。After the rows to be merged or the columns to be merged are determined through the above steps, when the cells in the rows or columns to be merged are merged, the reference cell can be determined first, and the reference cell can be used as the benchmark in the subsequent steps. The cells in the columns to be merged are merged.

具体的,在待合并行或待合并列中,可以将第一个内容不为空的单元格确定为第1基准单元格,将内容不为空、与前一单元格内容不同且与第n-1基准单元格内容不同的目标单元格确定为第n基准单元格。Specifically, in the row or column to be merged, the first cell whose content is not empty can be determined as the first reference cell, and the content is not empty, different from the content of the previous cell, and different from the n-1th cell. The target cell with different contents of the reference cell is determined as the nth reference cell.

假设通过步骤S101确定的是待合并行,在本步骤中,可以将待合并行中第一个内容不为空的单元格确定为第1基准单元格,然后可以在该行中确定满足第一预设条件的其他基准单元格,从而可以确定该行的所有基准单元格。Assuming that the row to be merged is determined through step S101, in this step, the first cell whose content is not empty in the row to be merged can be determined as the first reference cell, and then it can be determined in this row that the first preset cell is satisfied Other base cells for the condition, so that all base cells for the row can be determined.

需要说明的是,确定待合并列中的所有基准单元格的方法与确定待合并行中的所有基准单元格的方法相同或相似,这里不再赘述。It should be noted that the method for determining all the reference cells in the column to be merged is the same as or similar to the method for determining all the reference cells in the row to be merged, which will not be repeated here.

通过确定基准单元格,在对待合并行或待合并列中的单元格进行合并时,可以为进行合并的单元格提供合并基准,提高合并单元格的准确率。By determining the reference cell, when the cells in the row to be merged or the column to be merged are merged, a merge reference can be provided for the merged cells, and the accuracy of the merged cells can be improved.

S103,将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,得到处理后的数据表。S103, merge the cells from the n-1th reference cell to the cells before the nth reference cell into the n-1th merged cell, and merge the cells from the nth reference cell to the end cell into the nth merged cell grid to get the processed data table.

其中,终止单元格为在待合并行中第n基准单元格之后,所在列内容都为空的单元格,或者,在待合并列中第n基准单元格之后,所在行内容都为空的单元格。The terminating cell is a cell whose column content is empty after the nth reference cell in the row to be merged, or a cell whose row content is empty after the nth reference cell in the column to be merged.

需要说明的是,本步骤中的合并可以包括对单元格的合并和对单元格中内容的合并。It should be noted that the merging in this step may include merging of cells and merging of contents in cells.

在本步骤中,可以将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,得到处理后的数据表,即,合并单元格后的数据表。In this step, the cells from the n-1th reference cell to the nth reference cell can be merged into the n-1th merged cell, and the cells from the nth reference cell to the end cell can be merged into The nth cell is merged to obtain the processed data table, that is, the data table after the cells are merged.

具体的,在确定各基准单元格后,对待合并行或待合并列进行合并时,本发明实施例提供了两种可能的实现方式:Specifically, after each reference cell is determined, when the row to be merged or the column to be merged is merged, the embodiment of the present invention provides two possible implementation manners:

在一种可能的实现方式中,在第一个内容不为空的单元格为待合并行或待合并列中的第一个单元格时,可以通过以下方式对待合并行或待合并列进行合并:In a possible implementation, when the first cell whose content is not empty is the first cell in the row to be merged or the column to be merged, the row to be merged or the column to be merged can be merged in the following manner:

将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,得到处理后的数据表,这里,n为大于1的自然数。Merge the n-1th reference cell to the cells before the nth reference cell into the n-1th merged cell, and merge the nth reference cell to the cells before the termination cell into the nth merged cell, The processed data table is obtained, where n is a natural number greater than 1.

在另一种可能的实现方式中,在第一个内容不为空的单元格不是待合并行或待合并列中的第一个单元格时,可以将该第一个单元格至第2基准单元格之前的单元格合并为第1合并单元格,该待合并行或待合并列中的其他单元格可以通过以下方式进行合并:In another possible implementation, when the first cell whose content is not empty is not the first cell in the row or column to be merged, the first cell can be converted to the second reference cell The previous cells are merged into the 1st merged cell, and other cells in the row or column to be merged can be merged in the following ways:

将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,得到处理后的数据表,这里,n为大于2的自然数。Merge the n-1th reference cell to the cells before the nth reference cell into the n-1th merged cell, and merge the nth reference cell to the cells before the termination cell into the nth merged cell, The processed data table is obtained, where n is a natural number greater than 2.

假设,待处理数据表为表1,如表1所示,为待处理数据表的示意表,在该表中,第一列为确定的待合并列,第一个A对应的单元格为第1基准单元格,第一个B对应的单元格为第2基准单元格,与C对应的单元格为第3基准单元格。在对第一列中的单元格进行合并时,可以将第1基准单元格至第2基准单元格之前的单元格合并为第1合并单元格,即,将该列中第一行至第3行的单元格合并为第1合并单元格。将第2基准单元格至第3基准单元格之前的单元格合并为第2合并单元格,即,将该列中第4行至第6行的单元格合并为第2合并单元格。将第3基准单元格至终止单元格之前的单元格合并为第3合并单元格,其中,在该表中,终止单元格为在第一列中第3基准单元格之后,所在行内容都为空的单元格,即,在该表中,该终止单元格为第一列第九行对应的单元格。按照上述步骤执行合并操作后,可以得到如表2所示的处理后的数据表的示意表。在该示意表中,第一列为确定的待合并列,与A对应的单元格是第1合并单元格,与B对应的单元格是第2合并单元格,与C对应的单元格是第3合并单元格。Assume that the table of data to be processed is Table 1. As shown in Table 1, it is a schematic table of the data table to be processed. In this table, the first column is the determined column to be merged, and the cell corresponding to the first A is the first column. The reference cell, the cell corresponding to the first B is the second reference cell, and the cell corresponding to C is the third reference cell. When merging cells in the first column, the cells before the first reference cell to the second reference cell can be merged into the first merged cell, that is, the first row to the third in the column can be merged. The cells of the row are merged into the 1st merged cell. Merge the cells before the 2nd reference cell to the 3rd reference cell into the 2nd merged cell, that is, merge the cells in the 4th row to the 6th row in the column into the 2nd merged cell. Merge the cells from the 3rd reference cell to the terminating cell into the 3rd merged cell, where, in this table, the terminating cell is after the 3rd reference cell in the first column, and the content of the row is An empty cell, that is, in this table, the terminating cell is the cell corresponding to the ninth row of the first column. After the merging operation is performed according to the above steps, a schematic table of the processed data table as shown in Table 2 can be obtained. In this schematic table, the first column is the determined column to be merged, the cell corresponding to A is the first merged cell, the cell corresponding to B is the second merged cell, and the cell corresponding to C is the third merged cell Merge Cells.

表1待处理数据表的示意表Table 1 Schematic representation of pending data tables

AACCAADDEEBBFFBBGGHHCCIIJJ

表2处理后的数据表的示意表Table 2 Schematic representation of the processed data table

Figure BDA0001339899890000101
Figure BDA0001339899890000101

本发明实施例提供的一种合并单元格的方法,通过确定待处理数据表中的待合并行或待合并列,再确定基准单元格,然后将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,可以减少人工合并的操作,节省人力成本,并且,在待合并行或待合并列中存在内容为空的单元格时,能够实现正确合并单元格。In a method for merging cells provided by an embodiment of the present invention, the row or column to be merged in the data table to be processed is determined, the reference cell is determined, and then the n-1th reference cell is placed before the nth reference cell. merged cells into the n-1th merged cell, and merged the cells from the nth reference cell to the termination cell into the nth merged cell, which can reduce manual merging operations and save labor costs. Cells can be merged correctly when there are empty cells in the parallel or column to be merged.

在实施本发明实施例的一种合并单元格的方法时,本发明实施例提供了两种可能的实现方式:When implementing a method for merging cells according to the embodiment of the present invention, the embodiment of the present invention provides two possible implementation manners:

第一种可能的实现方式(这里以待合并列为一列进行说明):The first possible implementation (here, the columns to be merged are described as one column):

在确定待合并列后,可以在通过步骤S102的方法每确定一个基准单元格时,通过步骤S103的方法对该基准单元格的前一基准单元格至该基准单元格之前的单元格进行合并,即,边确定基准单元格,边合并该待合并列中的单元格。After the column to be merged is determined, each time a reference cell is determined by the method of step S102, the method of step S103 can be used to merge the previous reference cell of the reference cell to the cell before the reference cell, that is, , while determining the base cell, and merging the cells in the column to be merged.

在通过第一种可能的实现方式合并待合并列中的单元格时,可以将合并结果进行缓存,在对待合并列完成单元格合并后,再输出处理后的待处理数据表。When the cells in the column to be merged are merged through the first possible implementation manner, the merged result can be cached, and after the cells of the column to be merged are merged, the processed to-be-processed data table is output.

通过第一种可能的实现方式,可以降低同时对待合并行或待合并列中的单元格进行合并带来的负载压力,提高处理速度。Through the first possible implementation manner, the load pressure caused by merging the cells in the row or column to be merged at the same time can be reduced, and the processing speed can be improved.

第二种可能的实现方式(这里以待合并列为一列进行说明):The second possible implementation (here, the columns to be merged are described as one column):

在确定待合并列后,在该待合并列中,可以通过步骤S102的方法确定该待合并列中的所有基准单元格,然后通过步骤S103的方法对该待合并列中的单元格进行合并。After the column to be merged is determined, in the column to be merged, all reference cells in the column to be merged can be determined by the method of step S102, and then the cells in the column to be merged can be merged by the method of step S103.

通过第二种可能的实现方式,可以降低对缓存空间的占用,减少缓存占用缓存空间的时间。Through the second possible implementation manner, the occupancy of the cache space can be reduced, and the time that the cache occupies the cache space can be reduced.

需要说明的是,待合并行中的单元格合并方法与待合并列中的单元格的合并方法相同或相似,可以相互参照,这里不再赘述。It should be noted that the method for merging cells in the row to be merged is the same as or similar to the method for merging cells in the column to be merged, which can be referred to each other, and will not be repeated here.

具体的,在通过对待处理数据表中的每行或每列进行分析,确定待合并行或待合并列,可以包括:Specifically, after analyzing each row or column in the data table to be processed, the row or column to be merged is determined, which may include:

将待处理数据表中满足第二预设条件的行确定为待合并行,或者,将待处理数据表中满足第二预设条件的列确定为待合并列。A row in the data table to be processed that meets the second preset condition is determined as a row to be merged, or a column in the data table to be processed that meets the second preset condition is determined as a column to be merged.

其中,第二预设条件为在待处理数据表中的同一行或同一列中存在至少两个内容相同且相连的单元格,或,在待处理数据表中的同一行或同一列中存在至少一个内容为空的单元格。Wherein, the second preset condition is that there are at least two cells with the same content and connected in the same row or column in the data table to be processed, or, there are at least two cells in the same row or column in the data table to be processed A cell with empty content.

在本步骤中,在待处理数据表中的同一行中存在至少两个内容相同且相连的单元格或存在至少一个内容为空的单元格时,则该行确定为待合并行;In this step, when there are at least two cells with the same content and connected or at least one cell with empty content in the same row of the data table to be processed, the row is determined to be a row to be merged;

在待处理数据表中的同一列中存在至少两个内容相同且相连的单元格或存在至少一个内容为空的单元格时,则该列确定为待合并列。When there are at least two connected cells with the same content or at least one cell with empty content in the same column of the data table to be processed, the column is determined to be a column to be merged.

通过本步骤,可以实现通过本发明实施例的合并单元格的装置对待合并行或待合并列的确定,可以在仅接收到合并行、合并列或合并单元格的指令时,实现确定待合并行或待合并列,保证对待处理数据表中的单元格进行合并时能够正确合并。Through this step, the device for merging cells according to the embodiment of the present invention can determine the row to be merged or the column to be merged. Parallel to ensure that the cells in the data table to be processed can be merged correctly when merging.

在通过上述方法确定待处理数据表中的待合并行或待合并列后,在待处理数据表中存在两个以上待合并行或待合并列时,本发明实施例还提供了一种可能的实现方式。After determining the rows or columns to be merged in the data table to be processed by the above method, when there are more than two rows or columns to be merged in the data table to be processed, the embodiment of the present invention also provides a possible implementation manner.

具体的,在将待处理数据表中满足第二预设条件的行确定为待合并行,或者,将待处理数据表中满足第二预设条件的列确定为待合并列之后,本发明实施例的一种合并单元格的方法,还可以包括:Specifically, after determining a row in the data table to be processed that meets the second preset condition as a row to be merged, or after determining a column in the data table to be processed that meets the second preset condition as a column to be merged, the A method of merging cells, which can also include:

第一步,在待处理数据表中存在两个以上待合并行或待合并列时,发送携带有待合并行或待合并列的标识信息的待确认请求至用户;In the first step, when there are more than two rows or columns to be merged in the data table to be processed, a pending confirmation request carrying the identification information of the rows or columns to be merged is sent to the user;

具体的,该标识信息可以是待合并行的行号或待合并列的列号,还可以是与行号对应的该行的标记,或与列号对应的该列的标记。例如,第11行的行号为“Row11”、第5列的列号为“Column5”。Specifically, the identification information may be the row number of the row to be merged or the column number of the column to be merged, and may also be the mark of the row corresponding to the row number, or the mark of the column corresponding to the column number. For example, the row number of the 11th row is "Row11", and the column number of the 5th column is "Column5".

在本发明实施例的合并单元格的装置确定的待合并行为两行以上时,可以将该两行的标识信息添加到待确认请求信息中发送给用户,请求用户确认。When the device for merging cells in the embodiment of the present invention determines that there are more than two lines of behaviors to be merged, the identification information of the two lines may be added to the request information to be confirmed and sent to the user to request confirmation from the user.

在本发明实施例的合并单元格的装置确定的待合并列为两列以上时,可以将该两列的标识信息添加到待确认请求信息中发送给用户,请求用户确认。When the device for merging cells in the embodiment of the present invention determines that there are more than two columns to be merged, the identification information of the two columns may be added to the request information to be confirmed and sent to the user to request confirmation from the user.

在本发明实施例的合并单元格的装置确定的待合并行或待合并列中同时包括行和列时,可以将该行的标识信息和该列的标识信息同时添加到待确认请求信息中发送给用户,请求用户确认。When the row to be merged or the column to be merged determined by the apparatus for merging cells in the embodiment of the present invention includes both a row and a column, the identification information of the row and the identification information of the column may be added to the request information to be confirmed and sent to the user at the same time , asking the user for confirmation.

具体的,发送携带有待合并行或待合并列的标识信息的待确认请求至用户时,可以是在待处理数据表中弹出一个窗口,该窗口中可以包括待合并行的行号或待合并列的列号、选择框,还可以包括确认按钮。Specifically, when a pending confirmation request carrying the identification information of the row or column to be merged is sent to the user, a window may pop up in the data table to be processed, and the window may include the row number of the row to be merged or the column number of the column to be merged , a selection box, and optionally a confirm button.

第二步,获取并根据用户反馈的携带有待合并行或待合并列的标识信息的确认信息,确定待处理数据表中的待合并行或待合并列为包含标识信息的待合并行或待合并列。Step 2: Acquire and determine the rows or columns to be merged in the data table to be merged containing the identification information according to the confirmation information fed back by the user carrying the identification information of the rows or columns to be merged.

具体的,发送携带有待合并行或待合并列的标识信息的待确认请求至用户后,用户可以看到该待确认请求信息,可以根据携带的标识信息选择待合并行或待合并列。在用户选择待合并行或待合并列后,本发明实施例的合并单元格的装置可以获取到用户反馈的携带有待合并行或待合并列的标识信息的确认信息,然后可以根据该确认信息中的标识信息,确定待处理数据表中的待合并行或待合并列为包含该标识信息的待合并行或待合并列。Specifically, after sending a pending request carrying the identification information of the row or column to be merged to the user, the user can see the pending request information, and can select the row to be merged or the column to be merged according to the identification information carried. After the user selects the row to be merged or the column to be merged, the apparatus for merging cells according to the embodiment of the present invention may obtain confirmation information that carries the identification information of the row to be merged or the column to be merged fed back by the user, and then can be based on the identification information in the confirmation information. , and determine the rows or columns to be merged in the data table to be processed that include the rows or columns to be merged that include the identification information.

其中,用户反馈的标识信息可以与发送给用户的标识信息相同,也可以少于发送给用户的标识信息。The identification information fed back by the user may be the same as the identification information sent to the user, or may be less than the identification information sent to the user.

通过上述步骤,本发明实施例的合并单元格的装置可以在存在多行待合并行或多列待合并列时给用户提供选择,根据用户的确认信息合并待合并行或待合并列中的单元格,提高用户的体验。Through the above steps, the device for merging cells according to the embodiment of the present invention can provide a user with options when there are multiple rows to be merged or columns to be merged, and merge cells in the rows or columns to be merged according to the user's confirmation information, thereby improving the user experience. experience.

在对待合并行或待合并列中的单元格进行合并时,可以仅仅对单元格的内容及单元格进行合并,将合并后的单元格的属性设定为默认属性,也可以在对单元格的内容及单元格进行合并时,将合并后的单元格的属性设定为其中任一单元格的属性。When merging cells in the row or column to be merged, you can only merge the content of the cell and the cell, and set the attribute of the merged cell as the default attribute. When merging with cells, set the properties of the merged cells to the properties of any of the cells.

其中,该默认属性是在建立待处理数据表时,预先生成的属性。The default attribute is a pre-generated attribute when the data table to be processed is established.

具体的,将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,可以包括:Specifically, the cells from the n-1th reference cell to the cells before the nth reference cell are merged into the n-1th merged cell, and the cells from the nth reference cell to the termination cell are merged into the nth merged cell cells, which can include:

在第n-1基准单元格至第n基准单元格之前的单元格中存在属性不同的单元格时,将第n-1基准单元格至第n基准单元格之前的单元格中任一内容不为空的单元格的属性作为第n-1合并单元格的基准属性,将第n-1基准单元格至第n基准单元格之前的单元格的内容合并为第n-1合并单元格的内容,将第n-1基准单元格至第n基准单元格之前的单元格的属性合并为第n-1合并单元格的基准属性;When there are cells with different attributes in the cells before the n-1th reference cell to the nth reference cell, any content in the cells before the n-1th reference cell to the nth reference cell is not changed. The attribute of the empty cell is used as the base attribute of the n-1th merged cell, and the contents of the cells before the n-1th base cell to the nth base cell are merged into the content of the n-1th merged cell , merge the attributes of the n-1th reference cell to the cells before the nth reference cell into the reference attributes of the n-1th merged cell;

在第n基准单元格至终止单元格之前的单元格中存在属性不同的单元格时,将第n基准单元格至终止单元格之前的单元格中任一内容不为空的单元格的属性确定为第n合并单元格的基准属性,将第n基准单元格至终止单元格之前的单元格的内容合并为第n合并单元格的内容,将第n基准单元格至终止单元格之前的单元格的属性合并为第n合并单元格的基准属性。When there are cells with different attributes in the cells before the nth reference cell to the end cell, determine the attribute of any cell whose content is not empty among the cells from the nth reference cell to the end cell For the base attribute of the nth merged cell, merge the contents of the nth base cell to the cell before the end cell into the content of the nth merged cell, and merge the nth base cell to the cell before the end cell The attributes of are merged into the base attribute of the nth merged cell.

还可以包括:Can also include:

在第n-1基准单元格至第n基准单元格之前的单元格中存在属性不同的单元格时,将第n-1基准单元格的属性作为第n-1合并单元格的基准属性,将第n-1基准单元格至第n基准单元格之前的单元格的内容合并为第n-1合并单元格的内容,将第n-1基准单元格至第n基准单元格之前的单元格的属性合并为第n-1合并单元格的基准属性;When there are cells with different attributes in the cells from the n-1th reference cell to the nth reference cell, the attribute of the n-1th reference cell is used as the reference attribute of the n-1th merged cell, and the The contents of the n-1th reference cell to the cells before the nth reference cell are merged into the content of the n-1th merged cell, and the contents of the n-1th reference cell to the cells before the nth reference cell are merged. Attributes are merged into the base attribute of the n-1th merged cell;

在第n基准单元格至终止单元格之前的单元格中存在属性不同的单元格时,将第n基准单元格的属性确定为第n合并单元格的基准属性,将第n基准单元格至终止单元格之前的单元格的内容合并为第n合并单元格的内容,将第n基准单元格至终止单元格之前的单元格的属性合并为第n合并单元格的基准属性。即,可以将每个基准单元格的属性作为合并单元格的基准属性。When there are cells with different attributes in the cells before the nth reference cell to the termination cell, the attribute of the nth reference cell is determined as the reference attribute of the nth merged cell, and the nth reference cell to the termination cell is determined as the reference attribute of the nth merged cell. The content of the cell before the cell is merged into the content of the nth merged cell, and the attributes of the nth base cell to the cell before the end cell are merged into the base attribute of the nth merged cell. That is, the attribute of each base cell can be used as the base attribute of the merged cell.

具体的,该属性包括以下至少之一或其组合:字体、对齐方式、缩进间距、样式、单元格格式。Specifically, the attribute includes at least one or a combination of the following: font, alignment, indentation spacing, style, and cell format.

通过上述步骤,可以在对待合并行或待合并列中的单元格进行合并时,保证合并后的单元格的属性符合用户的设置,提高用户体验。Through the above steps, when merging cells in a row or column to be merged, it can be ensured that the attributes of the merged cells conform to user settings, thereby improving user experience.

本发明实施例还提供了一种合并单元格的方法,如图2所示,为本发明实施例的一种合并单元格的方法的第二种实施方式的流程图。该方法可以包括:An embodiment of the present invention further provides a method for merging cells, as shown in FIG. 2 , which is a flowchart of a second implementation manner of the method for merging cells according to an embodiment of the present invention. The method can include:

S201,将待处理数据表中满足第二预设条件的行确定为待合并行,或者,将待处理数据表中满足第二预设条件的列确定为待合并列。S201: Determine a row in the data table to be processed that meets a second preset condition as a row to be merged, or determine a column in the data table to be processed that meets the second preset condition as a column to be merged.

其中,第二预设条件为在待处理数据表中的同一行或同一列中存在至少两个内容相同且相连的单元格,或,在待处理数据表中的同一行或同一列中存在至少一个内容为空的单元格。Wherein, the second preset condition is that there are at least two cells with the same content and connected in the same row or column in the data table to be processed, or, there are at least two cells in the same row or column in the data table to be processed A cell with empty content.

假设,表3所示的待处理的数据表X为本发明实施例的待处理数据表,在该表中,包括4列14行。其中,第一列中的第一行和第二行分别对应的单元格的内容都为A,因此,第一列满足第二预设条件,可以将第一列确定为待合并列,第三列中的第一行至第三行分别对应的单元格的内容都为1,因此,第三列也满足第二预设条件,可以将第三列确定为待合并列。通过步骤S201确定的待合并列为第一列和第三列。It is assumed that the data table X to be processed shown in Table 3 is the data table to be processed according to the embodiment of the present invention, and the table includes 4 columns and 14 rows. The contents of the cells corresponding to the first row and the second row in the first column are both A. Therefore, if the first column satisfies the second preset condition, the first column can be determined as the column to be merged, and the third column can be determined as the column to be merged. The contents of the cells corresponding to the first row to the third row in are all 1. Therefore, the third column also satisfies the second preset condition, and the third column can be determined as the column to be merged. The columns to be merged determined in step S201 are the first column and the third column.

S202,在待处理数据表中存在两个以上待合并行或待合并列时,发送携带有待合并行或待合并列的标识信息的待确认请求至用户。S202, when there are more than two rows or columns to be merged in the data table to be merged, send a pending confirmation request carrying identification information of the rows or columns to be merged to the user.

由于通过上述步骤确定的待合并列为第一列和第三列,共两列,因此,这里可以请求用户确认是否对两列中的单元格都进行合并。Since the columns to be merged determined through the above steps are the first column and the third column, there are two columns in total, therefore, the user can be requested to confirm whether to merge cells in both columns.

具体的,可以发送携带有第一列的标识信息和第三列的标识信息的待确认请求给用户。Specifically, a pending confirmation request carrying the identification information of the first column and the identification information of the third column may be sent to the user.

表3待处理的数据表XTable 3 Pending Data Sheet X

AADD1155AAEE1166FF1177AAJJ2288BBHH99II221010BBJJ221111KK331212AALL331313MM1414AANN331515CCOO441616CCPP1717

S203,获取并根据用户反馈的携带有待合并行或待合并列的标识信息的确认信息,确定待处理数据表中的待合并行或待合并列为包含标识信息的待合并行或待合并列。S203: Acquire and according to the confirmation information fed back by the user carrying the identification information of the row to be merged or the column to be merged, determine the row to be merged or the column to be merged in the to-be-processed data table that contains the identification information.

用户在获取到该待确认请求后,可以根据待处理数据表中的内容及第一列的标识信息、第三列的标识信选择第一列为待合并列,或者,选择第三列为待合并列,或者,选择第一列和第三列为待合并列。After obtaining the pending confirmation request, the user can select the first column to be merged according to the content in the data table to be processed, the identification information of the first column, and the identification letter of the third column, or select the third column to be merged. , or, select the first and third columns to combine.

假设用户选择第一列为待合并列,本发明实施例的合并单元格的装置可以获取到用户反馈的携带有该第一列的标识信息的确认信息,可以确定待处理数据表中的待合并列为包含第一列的标识信息的待合并列。Assuming that the user selects the first column as the column to be merged, the apparatus for merging cells in the embodiment of the present invention can obtain the confirmation information that carries the identification information of the first column fed back by the user, and can determine the column to be merged in the data table to be processed. The column to be merged that contains the identifying information of the first column.

S204,在待合并行或待合并列中,将第一个内容不为空的单元格确定为第1基准单元格,将满足第一预设条件的目标单元格确定为第n基准单元格。S204, in the row or column to be merged, determine the first cell whose content is not empty as the first reference cell, and determine the target cell that satisfies the first preset condition as the nth reference cell.

其中,第一预设条件为目标单元格内容不为空、与前一单元格内容不同且与第n-1基准单元格内容不同,n为大于1的自然数,目标单元格为待合并行或待合并列中第n-1基准单元格之后的单元格。Among them, the first preset condition is that the content of the target cell is not empty, is different from the content of the previous cell, and is different from the content of the n-1th reference cell, n is a natural number greater than 1, and the target cell is the row to be merged or to be merged. The cell after the n-1th base cell in the tie.

在通过上述步骤确定第一列为该数据表的待合并列后,为了对该列中的单元格进行正确的合并,可以对该列中的单元格进行分析,从而确定合理的合并方式。为此,本发明实施例提供了一种可能的方式,即,将第一个内容不为空的单元格确定为第1基准单元格,将满足第一预设条件的目标单元格确定为第n基准单元格。After the first column is determined to be the to-be-merged column of the data table through the above steps, in order to correctly merge the cells in the column, the cells in the column can be analyzed to determine a reasonable merging method. To this end, the embodiment of the present invention provides a possible way, that is, the first cell whose content is not empty is determined as the first reference cell, and the target cell that satisfies the first preset condition is determined as the first reference cell. nBase cells.

例如,在第一列中,第一个内容不为空的单元格为第一行的单元格,即,第一个单元格内容为A的单元格,将该第一列第一行的单元格确定为第1基准单元格。For example, in the first column, the first cell whose content is not empty is the cell in the first row, that is, the first cell whose content is A, the cell in the first row of the first column The cell is determined as the first reference cell.

在第1基准单元格之后,第一列第五行的单元格的内容为B,单元格内容不为空、与第1基准单元格内容不同,并且与该列中第四行的单元格的内容不同,因此,可以将第一列第五行的单元格确定为第2基准单元。After the first reference cell, the content of the cell in the fifth row of the first column is B, the content of the cell is not empty, different from the content of the first reference cell, and the content of the cell in the fourth row of the column Therefore, the cell in the first column and the fifth row can be determined as the second reference cell.

在第2基准单元格之后,第一列第九行的单元格的内容为A,单元格内容不为空、与第2基准单元格内容不同,并且与该列中第八行的单元格的内容不同,因此,可以将第一列第九行的单元格确定为第3基准单元格。After the second reference cell, the content of the cell in the ninth row of the first column is A, the content of the cell is not empty, different from the content of the second reference cell, and the content of the cell in the eighth row in the column is A. The contents are different, therefore, the cell in the ninth row of the first column can be determined as the third reference cell.

通过本步骤S204,可以确定数据表X中第一列第十二行的单元格确定为第4基准单元格。Through this step S204, it can be determined that the cell in the twelfth row of the first column in the data table X is determined as the fourth reference cell.

通过确定基准单元格,能够实现在后续步骤对待合并列中单元格进行正确的合并,提高合并单元格的正确率。By determining the reference cell, the cells in the column to be merged can be correctly merged in the subsequent steps, and the accuracy of the merged cells can be improved.

S205,判断第n-1基准单元格至第n基准单元格之前的单元格的属性是否相同,第n基准单元格至终止单元格之前的单元格的属性是否相同。S205: Determine whether the attributes of the cells before the n-1th reference cell to the nth reference cell are the same, and whether the attributes of the cells before the nth reference cell to the termination cell are the same.

其中,终止单元格为在待合并行中第n基准单元格之后,所在列内容都为空的单元格,或者,在待合并列中第n基准单元格之后,所在行内容都为空的单元格。The terminating cell is a cell whose column content is empty after the nth reference cell in the row to be merged, or a cell whose row content is empty after the nth reference cell in the column to be merged.

具体的,在确定待合并列或待合并行中的基准单元格后,可以判断单元格的属性是否相同。Specifically, after determining the reference cells in the columns or rows to be merged, it can be determined whether the attributes of the cells are the same.

例如,可以在确定数据表X的第一列中的基准单元格后,判断该列中第1基准单元格至第2基准单元格之前的单元格的属性是否相同,判断第2基准单元格至第3基准单元格之前的单元格的属性是否相同,判断第3基准单元格至第4基准单元格之前的单元格的属性是否相同,判断第4基准单元格至终止单元格之前的单元格的属性是否相同。For example, after determining the reference cell in the first column of the data table X, it can be determined whether the attributes of the cells before the first reference cell to the second reference cell in the column are the same, and the second reference cell to the second reference cell can be determined. Whether the attributes of the cells before the 3rd reference cell are the same, determine whether the attributes of the cells before the 3rd reference cell to the 4th reference cell are the same, and judge whether the attributes of the cells before the 4th reference cell to the end cell are the same. properties are the same.

其中,由于在该数据表X中第14行中各单元格的内容都为空,可以将第一列第14行对应的单元格确定为终止单元格。Among them, since the content of each cell in the 14th row of the data table X is empty, the cell corresponding to the 14th row of the first column can be determined as the termination cell.

S206,在第n-1基准单元格至第n基准单元格之前的单元格的属性相同时,将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,得到处理后的数据表。S206, when the attributes of the cells before the n-1th reference cell to the nth reference cell are the same, merge the cells from the n-1th reference cell to the cells before the nth reference cell into the n-1th merge cell, merge the cells from the nth reference cell to the end cell into the nth merged cell to obtain the processed data table.

假设,第一列中第1基准单元格至第2基准单元格之前的单元格的属性相同,第2基准单元格至第3基准单元格之前的单元格的属性相同,第3基准单元格至第4基准单元格之前的单元格的属性相同,判断第4基准单元格至终止单元格之前的单元格的属性相同。则可以通过步骤S206的方法对第一列进行单元格合并。Assume that the attributes of the cells before the 1st reference cell to the 2nd reference cell in the first column are the same, the attributes of the cells before the 2nd reference cell to the 3rd reference cell are the same, and the 3rd reference cell to The attributes of the cells before the fourth reference cell are the same, and it is judged that the attributes of the cells before the fourth reference cell to the termination cell are the same. Then, the cells of the first column can be merged by the method of step S206.

具体的,可以将第一列中第一行至第四行的单元格合并为第1合并单元格,将该列中第一行至第四行的单元格的内容合并为A,即,第1合并单元格的内容为A。Specifically, the cells in the first row to the fourth row in the first column can be merged into the first merged cell, and the contents of the cells in the first row to the fourth row in the column can be merged into A, that is, the first 1 The content of the merged cell is A.

可以将该列中第五行至第八行的单元格合并为第2合并单元格,将该列中第五行至第八行的单元格的内容合并为B,即,第2合并单元格的内容为B。The cells in the fifth row to the eighth row in the column can be merged into the second merged cell, and the contents of the cells in the fifth row to the eighth row in the column can be merged into B, that is, the content of the second merged cell for B.

将该列中第九行至十一行的单元格合并为第3合并单元格,将该列中第九行至十一行的单元格的内容合并A,即,第3合并单元格的内容为A。Merge the cells in the ninth row to the eleventh row in the column into the third merged cell, and merge the contents of the cells in the ninth row to the eleventh row in the column A, that is, the content of the third merged cell for A.

将该列中第十二行至第十三行的单元格合并为第4合并单元格,将该列中第十二行至第十三行的单元格的内容合并为C,即,第4合并单元格的内容为C。Merge the cells in the twelfth row to the thirteenth row in this column into the 4th merged cell, and merge the contents of the cells in the twelfth row to the thirteenth row in the column into C, that is, the 4th The content of the merged cell is C.

S207,在第n-1基准单元格至第n基准单元格之前的单元格中存在属性不同的单元格时,将第n-1基准单元格至第n基准单元格之前的单元格中任一内容不为空的单元格的属性作为第n-1合并单元格的基准属性,将第n-1基准单元格至第n基准单元格之前的单元格的内容合并为第n-1合并单元格的内容,将第n-1基准单元格至第n基准单元格之前的单元格的属性合并为第n-1合并单元格的基准属性;S207, when there are cells with different attributes in the cells before the n-1th reference cell to the nth reference cell, change any one of the cells from the n-1th reference cell to the cells before the nth reference cell The attribute of the cell whose content is not empty is used as the base attribute of the n-1th merged cell, and the content of the cell from the n-1th base cell to the nth base cell is merged into the n-1th merged cell. , merge the attributes of the n-1th base cell to the cells before the nth base cell into the base attributes of the n-1th merged cell;

S208,在第n基准单元格至终止单元格之前的单元格中存在属性不同的单元格时,将第n基准单元格至终止单元格之前的单元格中任一内容不为空的单元格的属性确定为第n合并单元格的基准属性,将第n基准单元格至终止单元格之前的单元格的内容合并为第n合并单元格的内容,将第n基准单元格至终止单元格之前的单元格的属性合并为第n合并单元格的基准属性。S208, when there are cells with different attributes in the cells before the nth reference cell to the terminating cell, set any cell whose content is not empty in the nth reference cell to the cells before the terminating cell. The attribute is determined as the base attribute of the nth merged cell, the contents of the nth base cell to the cell before the termination cell are merged into the content of the nth merged cell, and the nth base cell to the end cell is merged. The attributes of the cells are merged into the base attribute of the nth merged cell.

假设,第1基准单元格至第2基准单元格之前的单元格的属性不同,在对第1基准单元格至第2基准单元格之前的单元格进行合并时,可以将第1基准单元格至第2基准单元格之前的单元格中任一内容不为空的单元格的属性确定为第1合并单元格的基准属性,将第1基准单元格至第2基准单元格之前的单元格合并为第1合并单元格,第1基准单元格至第2基准单元格之前的单元格的内容合并为第1基准单元格的内容,将第1基准单元格至第2基准单元格之前的单元格的属性合并为基准属性。Assuming that the attributes of the cells before the first reference cell and the second reference cell are different, when merging the cells between the first reference cell and the second reference cell, the first reference cell to the second reference cell can be merged. The attribute of any cell that is not empty in the cells before the 2nd reference cell is determined as the reference attribute of the 1st merged cell, and the cells from the 1st reference cell to the 2nd reference cell are merged into The 1st merged cell, the contents of the 1st reference cell to the cell before the 2nd reference cell are merged into the content of the 1st reference cell, the Attributes are merged into base attributes.

也就是说,将第一列中第一行至第四行的单元格合并为第1合并单元格,将该列中第一行至第四行的单元格的内容合并为A,即,第1合并单元格的内容为A,将第一列中第一行至第四行的单元格的属性合并为基准属性。That is, the cells in the first row to the fourth row in the first column are merged into the first merged cell, and the contents of the cells in the first row to the fourth row in the column are merged into A, that is, the first 1 The content of the merged cell is A, and the attributes of the cells in the first row to the fourth row in the first column are merged into the base attribute.

假设,将第一列第二行的单元格的属性确定为基准属性,则可以将第一列中第一行至第四行的单元格的属性合并为第一列第二行的单元格的属性。Assuming that the attributes of the cells in the first column and the second row are determined as the benchmark attributes, the attributes of the cells in the first row to the fourth row in the first column can be merged into the attributes of the cells in the first column and the second row. Attributes.

假设,第4基准单元格至终止单元格之前的单元格的属性不同,在对第4基准单元格至终止单元格之前的单元格进行合并时,可以将第4基准单元格至终止单元格之前的单元格中任一内容不为空的单元格的属性确定为第4合并单元格的基准属性。将第4基准单元格至终止单元格之前的单元格合并为第4合并单元格,将第4基准单元格至终止单元格之前的单元格的内容合并为第4合并单元格的内容,将第4基准单元格至终止单元格之前的单元格的属性合并为基准属性。Assuming that the properties of cells from the fourth reference cell to the end cell are different, when merging the cells from the fourth reference cell to the end cell, the fourth reference cell to the end cell can be merged. The attribute of any cell whose content is not empty is determined as the base attribute of the 4th merged cell. Merge the cells from the 4th reference cell to the end cell into the 4th merged cell, merge the contents of the 4th reference cell to the cell before the end cell into the content of the 4th merged cell, 4 The attributes of the base cell to the cell before the end cell are merged into base attributes.

也就是说,将第一列中第十二行至第十三行的单元格合并为第4合并单元格,将该列中第十二行至第十三行的单元格的内容合并为C,即,第4合并单元格的内容为C,将第一列中第十二行至第十三行的单元格的属性合并为基准属性。That is, the cells in the 12th row to the thirteenth row in the first column are merged into the 4th merged cell, and the contents of the cells in the twelfth row to the thirteenth row in the column are merged into C , that is, the content of the fourth merged cell is C, and the attributes of the cells in the twelfth row to the thirteenth row in the first column are merged into the reference attribute.

假设,将第一列第十三行的单元格的属性确定为基准属性,可以将第一列中第十二行至第十三行的单元格的属性合并为第一列第十三行的单元格的属性。Assuming that the attributes of the cells in the thirteenth row of the first column are determined as the reference attributes, the attributes of the cells in the twelfth row to the thirteenth row in the first column can be merged into the attributes of the cells in the thirteenth row of the first column. properties of the cell.

通过本发明实施例提供的一种合并单元格的方法的第二种实施方式,可以得到处理后的数据表X,如表4所示,为对第一列合并处理后的数据表X,在该表中,第1合并单元格对应于待处理数据表X中的第一列第一行至第四行的单元格,第1合并单元格的内容为A,第2合并单元格对应于待处理数据表X中的第一列第五行至第八行的单元格,第2合并单元格的内容为B,第3合并单元格对应于待处理数据表X中的第九行至第十一行的单元格,第3合并单元格的内容为A,第4合并单元格对应于待处理数据表中的第十二行至第十三行的单元格,第4合并单元格的内容为C。Through the second implementation of the method for merging cells provided in the embodiment of the present invention, the processed data table X can be obtained. In this table, the first merged cell corresponds to the cells in the first row to the fourth row in the first column of the data table X to be processed, the content of the first merged cell is A, and the second merged cell corresponds to the pending data table X. Process the cells from the fifth row to the eighth row in the first column of the data table X, the content of the second merged cell is B, and the third merged cell corresponds to the ninth to eleventh rows in the data table X to be processed The cell of the row, the content of the 3rd merged cell is A, the 4th merged cell corresponds to the cells in the twelfth row to the thirteenth row in the data table to be processed, and the content of the 4th merged cell is C .

表4对第一列合并处理后的数据表XTable 4 merges the first column of data table X

Figure BDA0001339899890000191
Figure BDA0001339899890000191

应当理解的是,在用户选择第三列为待合并列时,也可以通过上述的方法对第三列的单元格进行合并,具体合并过程可以借鉴上述对第一列的单元格进行合并的方法,这里不再赘述。It should be understood that when the user selects the column to be merged in the third column, the cells in the third column can also be merged by the above method. I won't go into details here.

在用户选择第三列为待合并列时,处理后的数据表X如表5所示,为对第三列合并处理后的数据表X。When the user selects the third column to be merged, the processed data table X is shown in Table 5, which is the processed data table X after the third column is merged.

表5对第三列合并处理后的数据表XTable 5 merges the third column of data table X

Figure BDA0001339899890000201
Figure BDA0001339899890000201

相应于上述方法实施例,本发明实施例还提供了一种合并单元格的装置,如图3所示,为本发明实施例的一种合并单元格的装置的结构示意图,该装置可以包括:Corresponding to the above method embodiments, an embodiment of the present invention further provides an apparatus for merging cells. As shown in FIG. 3 , which is a schematic structural diagram of an apparatus for merging cells according to an embodiment of the present invention, the apparatus may include:

行列确定模块301,用于确定待处理数据表中的待合并行或待合并列,其中,待合并行或待合并列中包括至少两个内容相同且相连的单元格,或,待合并行或待合并列中包括至少一个内容为空的单元格;The row andcolumn determination module 301 is configured to determine the row to be merged or the column to be merged in the data table to be processed, wherein, the row to be merged or the column to be merged includes at least two cells with the same content and connected, or, the row to be merged or the column to be merged includes at least two cells. an empty cell;

基准单元格确定模块302,用于在待合并行或待合并列中,将第一个内容不为空的单元格确定为第1基准单元格,将满足第一预设条件的目标单元格确定为第n基准单元格,其中,第一预设条件为目标单元格内容不为空、与前一单元格内容不同且与第n-1基准单元格内容不同,n为大于1的自然数,目标单元格为待合并行或待合并列中第n-1基准单元格之后的单元格;The referencecell determination module 302 is configured to, in the row or column to be merged, determine the first cell whose content is not empty as the first reference cell, and determine the target cell that satisfies the first preset condition as the first cell. n reference cells, wherein the first preset condition is that the content of the target cell is not empty, is different from the content of the previous cell, and is different from the content of the n-1th reference cell, n is a natural number greater than 1, and the target cell is the cell after the n-1th reference cell in the row or column to be merged;

合并模块303,用于将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,得到处理后的数据表,其中,终止单元格为在待合并行中第n基准单元格之后,所在列内容都为空的单元格,或者,在待合并列中第n基准单元格之后,所在行内容都为空的单元格。The mergingmodule 303 is configured to merge the cells from the n-1th reference cell to the cells before the nth reference cell into the n-1th merged cell, and merge the cells from the nth reference cell to the termination cell into a The nth merged cell is obtained to obtain the processed data table, wherein the terminating cell is the cell whose column content is empty after the nth reference cell in the row to be merged, or the nth reference cell in the column to be merged After the cell, the content of the row is empty.

本发明实施例提供的一种合并单元格的装置,通过确定待处理数据表中的待合并行或待合并列,再确定基准单元格,然后将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,可以减少人工合并的操作,节省人力成本,并且,在待合并行或待合并列中存在内容为空的单元格时,能够实现正确合并单元格。An apparatus for merging cells provided by an embodiment of the present invention determines a reference cell by determining a row or column to be merged in a data table to be processed, and then sets the n-1th reference cell to the front of the nth reference cell. merged cells into the n-1th merged cell, and merged the cells from the nth reference cell to the termination cell into the nth merged cell, which can reduce manual merging operations and save labor costs. Cells can be merged correctly when there are empty cells in the parallel or column to be merged.

具体的,行列确定模块301,具体用于:Specifically, the row andcolumn determination module 301 is specifically used for:

将待处理数据表中满足第二预设条件的行确定为待合并行,或者,将待处理数据表中满足第二预设条件的列确定为待合并列,其中,第二预设条件为在待处理数据表中的同一行或同一列中存在至少两个内容相同且相连的单元格,或,在待处理数据表中的同一行或同一列中存在至少一个内容为空的单元格。Determining a row that satisfies the second preset condition in the data table to be processed is a row to be merged, or, determining a column that satisfies the second preset condition in the data table to be processed as a column to be merged, wherein the second preset condition is the row to be merged. There are at least two cells with the same content and connected in the same row or column in the data table to be processed, or at least one cell with empty content in the same row or column in the data table to be processed.

具体的,本发明实施例的一种合并单元格的装置,还包括:Specifically, an apparatus for merging cells according to an embodiment of the present invention further includes:

发送模块,用于在待处理数据表中存在两个以上待合并行或待合并列时,发送携带有待合并行或待合并列的标识信息的待确认请求至用户;A sending module, configured to send a pending confirmation request carrying the identification information of the rows or columns to be merged to the user when there are more than two rows or columns to be merged in the data table to be merged;

获取模块,用于获取并根据用户反馈的携带有待合并行或待合并列的标识信息的确认信息,确定待处理数据表中的待合并行或待合并列为包含标识信息的待合并行或待合并列。The obtaining module is used for obtaining and according to the confirmation information fed back by the user carrying the identification information of the row or column to be merged, to determine the row to be merged or the column to be merged in the to-be-processed data table that contains the identification information.

具体的,合并模块303,具体用于:Specifically, the mergingmodule 303 is specifically used for:

在第n-1基准单元格至第n基准单元格之前的单元格中存在属性不同的单元格时,将第n-1基准单元格至第n基准单元格之前的单元格中任一内容不为空的单元格的属性作为第n-1合并单元格的基准属性,将第n-1基准单元格至第n基准单元格之前的单元格的内容合并为第n-1合并单元格的内容,将第n-1基准单元格至第n基准单元格之前的单元格的属性合并为第n-1合并单元格的基准属性;When there are cells with different attributes in the cells before the n-1th reference cell to the nth reference cell, any content in the cells before the n-1th reference cell to the nth reference cell is not changed. The attribute of the empty cell is used as the base attribute of the n-1th merged cell, and the contents of the cells before the n-1th base cell to the nth base cell are merged into the content of the n-1th merged cell , merge the attributes of the n-1th reference cell to the cells before the nth reference cell into the reference attributes of the n-1th merged cell;

在第n基准单元格至终止单元格之前的单元格中存在属性不同的单元格时,将第n基准单元格至终止单元格之前的单元格中任一内容不为空的单元格的属性确定为第n合并单元格的基准属性,将第n基准单元格至终止单元格之前的单元格的内容合并为第n合并单元格的内容,将第n基准单元格至终止单元格之前的单元格的属性合并为第n合并单元格的基准属性。When there are cells with different attributes in the cells before the nth reference cell to the end cell, determine the attribute of any cell whose content is not empty among the cells from the nth reference cell to the end cell For the base attribute of the nth merged cell, merge the contents of the nth base cell to the cell before the end cell into the content of the nth merged cell, and merge the nth base cell to the cell before the end cell The attributes of are merged into the base attribute of the nth merged cell.

具体的,该属性包括以下至少之一或其组合:字体、对齐方式、缩进间距、样式、单元格格式。Specifically, the attribute includes at least one or a combination of the following: font, alignment, indentation spacing, style, and cell format.

本发明实施例还提供了一种电子设备,如图4所示,为本发明实施例的一种合并单元格的方法应用于电子设备的结构示意图,该电子设备可以包括:处理器401、通信接口402、存储器403和通信总线404,其中,处理器401、通信接口402、存储器403通过通信总线404完成相互间的通信;An embodiment of the present invention also provides an electronic device. As shown in FIG. 4 , it is a schematic structural diagram of a method for merging cells according to an embodiment of the present invention applied to an electronic device. The electronic device may include: aprocessor 401, a communication Theinterface 402, thememory 403 and thecommunication bus 404, wherein theprocessor 401, thecommunication interface 402, and thememory 403 complete the communication with each other through thecommunication bus 404;

存储器403,用于存储计算机程序;memory 403 for storing computer programs;

处理器401,用于执行存储器403上所存储的程序时,实现如下步骤:When theprocessor 401 is used to execute the program stored in thememory 403, the following steps are implemented:

步骤A,确定待处理数据表中的待合并行或待合并列;Step A, determine the row to be merged or the column to be merged in the data table to be processed;

步骤B,在待合并行或待合并列中,将第一个内容不为空的单元格确定为第1基准单元格,将满足第一预设条件的目标单元格确定为第n基准单元格;Step B, in the row to be merged or the column to be merged, the first cell whose content is not empty is determined as the first reference cell, and the target cell that satisfies the first preset condition is determined as the nth reference cell;

步骤C,将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,得到处理后的数据表。Step C, merge the cells from the n-1th reference cell to the nth reference cell into the n-1th merged cell, and merge the nth reference cell to the cells before the termination cell into the nth merge cell to get the processed data table.

上述电子设备提到的通信总线404可以是外设部件互连标准(PeripheralComponent Interconnect,PCI)总线或扩展工业标准结构(Extended Industry StandardArchitecture,EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中用二维双向箭头线表示,但并不表示仅有一根总线或一种类型的总线。Thecommunication bus 404 mentioned in the above electronic device may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an Extended Industry Standard Architecture (Extended Industry Standard Architecture, EISA) bus or the like. The communication bus can be divided into an address bus, a data bus, a control bus, and the like. For convenience of representation, the figure is represented by a two-dimensional two-way arrow line, but it does not mean that there is only one bus or one type of bus.

通信接口402用于上述电子设备与外部设备之间的通信。Thecommunication interface 402 is used for communication between the above-mentioned electronic device and external devices.

存储器403可以包括随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如,至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器401的存储装置。Thememory 403 may include random access memory (Random Access Memory, RAM), or may include non-volatile memory (Non-Volatile Memory, NVM), for example, at least one disk storage. Optionally, the memory may also be at least one storage device located away from theaforementioned processor 401 .

上述的处理器401可以是通用处理器,包括中央处理器(Central ProcessingUnit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(DigitalSignal Processing,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The above-mentionedprocessor 401 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; may also be a digital signal processor (Digital Signal Processing, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

本发明实施例还提供了一种计算机可读存储介质,该存储介质内存储有计算机程序,该计算机程序可以被处理器执行,以实现以下方法:Embodiments of the present invention also provide a computer-readable storage medium, where a computer program is stored in the storage medium, and the computer program can be executed by a processor to implement the following method:

步骤A,确定待处理数据表中的待合并行或待合并列;Step A, determine the row to be merged or the column to be merged in the data table to be processed;

步骤B,在待合并行或待合并列中,将第一个内容不为空的单元格确定为第1基准单元格,将满足第一预设条件的目标单元格确定为第n基准单元格;Step B, in the row to be merged or the column to be merged, the first cell whose content is not empty is determined as the first reference cell, and the target cell that satisfies the first preset condition is determined as the nth reference cell;

步骤C,将第n-1基准单元格至第n基准单元格之前的单元格合并为第n-1合并单元格,将第n基准单元格至终止单元格之前的单元格合并为第n合并单元格,得到处理后的数据表。Step C, merge the cells from the n-1th reference cell to the nth reference cell into the n-1th merged cell, and merge the nth reference cell to the cells before the termination cell into the nth merge cell to get the processed data table.

需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any relationship between these entities or operations. any such actual relationship or sequence exists. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device comprising a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.

本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a related manner, and the same and similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for related parts, please refer to the partial descriptions of the method embodiments.

以上所述仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本发明的保护范围内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (12)

1. A method of consolidating cells, the method comprising:
determining to-be-combined parallel or to-be-combined parallel in a to-be-processed data table, wherein the to-be-combined parallel or the to-be-combined column comprises at least two cells with the same content and connected with each other, or the to-be-combined parallel or the to-be-combined column comprises at least one cell with empty content;
in the row to be merged or the parallel to be merged, determining a cell with a first content which is not empty as a 1 st reference cell, and determining a target cell meeting a first preset condition as an nth reference cell, wherein the first preset condition is that the target cell is not empty, is different from the content of a previous cell and is different from the content of an n-1 th reference cell, n is a natural number greater than 1, and the target cell is the parallel to be merged or a cell behind the n-1 th reference cell in the parallel to be merged;
merging the cells before the n-1 th reference cell and the n-1 th reference cell into an n-1 th merged cell, and merging the cells before the n-1 th reference cell and the termination cell into an n-th merged cell to obtain a processed data table, wherein the termination cell is a cell whose column contents are all empty after the n-1 th reference cell in the to-be-merged row, or a cell whose row contents are all empty after the n-1 th reference cell in the to-be-merged row.
2. The method of claim 1, wherein determining the pending parallel or pending column in the pending data table comprises:
determining rows meeting a second preset condition in the to-be-processed data table as to-be-merged rows, or determining columns meeting the second preset condition in the to-be-processed data table as to-be-merged rows, wherein the second preset condition is that at least two cells with the same content and connected with each other exist in the same row or the same column in the to-be-processed data table, or at least one cell with empty content exists in the same row or the same column in the to-be-processed data table.
3. The method according to claim 2, wherein after determining a row in the to-be-processed data table that meets a second preset condition as a to-be-merged row or determining a column in the to-be-processed data table that meets the second preset condition as a to-be-merged column, the method further comprises:
when more than two rows to be merged or columns to be merged exist in the data table to be processed, sending a request to be confirmed carrying identification information of the rows to be merged or the columns to be merged to a user;
and determining the to-be-combined parallel or to-be-combined column in the to-be-processed data table as to-be-combined parallel or to-be-combined parallel containing the identification information according to the confirmation information which is fed back by the user and carries the identification information of the to-be-combined parallel or the to-be-combined parallel.
4. The method according to claim 1, wherein the merging the cells before the n-1 th reference cell to the n-1 th reference cell into an n-1 th merged cell, and the merging the n-th reference cell to the cell before the termination cell into an n-th merged cell comprises:
when cells with different attributes exist in cells before the n-1 th reference cell to the n-th reference cell, taking the attribute of any cell with contents which are not empty in the cells before the n-1 th reference cell to the n-1 th reference cell as the reference attribute of the n-1 th merged cell, merging the contents of the cells before the n-1 th reference cell to the n-1 th merged cell into the contents of the n-1 th merged cell, and merging the attributes of the cells before the n-1 th reference cell to the n-1 th reference cell into the reference attribute of the n-1 th merged cell;
when cells with different attributes exist in the cells before the nth reference cell to the termination cell, determining the attribute of any cell, the content of which is not empty, in the cells before the nth reference cell to the termination cell as the reference attribute of the nth merged cell, merging the content of the cells before the nth reference cell to the termination cell into the content of the nth merged cell, and merging the attribute of the cells before the nth reference cell to the termination cell into the reference attribute of the nth merged cell.
5. The method of claim 4, wherein the attributes comprise at least one of the following or a combination thereof: font, alignment, indentation distance, style, cell format.
6. An apparatus for consolidating cells, the apparatus comprising:
a rank determining module, configured to determine a to-be-combined parallel column or a to-be-combined parallel column in a to-be-processed data table, where the to-be-combined parallel column or the to-be-combined column includes at least two cells with the same content and connected to each other, or the to-be-combined parallel column or the to-be-combined column includes at least one cell with empty content;
a reference cell determining module, configured to determine, in the row to be merged or the parallel to be merged, a cell whose first content is not empty as a reference cell 1, and determine a target cell that meets a first preset condition as an nth reference cell, where the first preset condition is that the target cell content is not empty, is different from a previous cell content, and is different from an nth-1 reference cell content, n is a natural number greater than 1, and the target cell is the cell to be merged or behind the nth-1 reference cell in the parallel to be merged;
a merging module, configured to merge cells before the n-1 th reference cell and the nth reference cell into an n-1 th merged cell, merge cells before the n-1 th reference cell and the terminating cell into an nth merged cell, and obtain a processed data table, where the terminating cell is a cell whose column content is empty after the n-1 th reference cell in the to-be-merged row, or a cell whose row content is empty after the n-1 th reference cell in the to-be-merged row.
7. The apparatus of claim 6, wherein the rank determination module is specifically configured to:
determining rows meeting a second preset condition in the to-be-processed data table as to-be-merged rows, or determining columns meeting the second preset condition in the to-be-processed data table as to-be-merged rows, wherein the second preset condition is that at least two cells with the same content and connected with each other exist in the same row or the same column in the to-be-processed data table, or at least one cell with empty content exists in the same row or the same column in the to-be-processed data table.
8. The apparatus of claim 7, further comprising:
a sending module, configured to send a request to be confirmed to a user, where the request carries identification information of a row to be merged or a column to be merged, when more than two rows to be merged or rows to be merged exist in the data table to be processed;
and the acquisition module is used for acquiring and determining whether the to-be-combined parallel or the to-be-combined parallel in the to-be-processed data table is to-be-combined parallel or to-be-combined parallel containing the identification information according to the confirmation information which is fed back by the user and carries the identification information of the to-be-combined parallel or the to-be-combined parallel.
9. The apparatus of claim 6, wherein the merging module is specifically configured to:
when cells with different attributes exist in cells before the n-1 th reference cell to the n-th reference cell, taking the attribute of any cell with contents which are not empty in the cells before the n-1 th reference cell to the n-1 th reference cell as the reference attribute of the n-1 th merged cell, merging the contents of the cells before the n-1 th reference cell to the n-1 th merged cell into the contents of the n-1 th merged cell, and merging the attributes of the cells before the n-1 th reference cell to the n-1 th reference cell into the reference attribute of the n-1 th merged cell;
when cells with different attributes exist in the cells before the nth reference cell to the termination cell, determining the attribute of any cell, the content of which is not empty, in the cells before the nth reference cell to the termination cell as the reference attribute of the nth merged cell, merging the content of the cells before the nth reference cell to the termination cell into the content of the nth merged cell, and merging the attribute of the cells before the nth reference cell to the termination cell into the reference attribute of the nth merged cell.
10. The apparatus of claim 9, wherein the attribute comprises at least one of the following or a combination thereof: font, alignment, indentation distance, style, cell format.
11. An electronic device, comprising: the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
the memory for storing a computer program;
the processor, when executing the program stored in the memory, implementing the method steps of any of claims 1-5;
the communication interface is used for data exchange between the electronic equipment and external equipment.
12. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method steps of any one of claims 1 to 5.
CN201710533329.8A2017-07-032017-07-03Method and device for merging cells, electronic equipment and readable storage mediumActiveCN109213978B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201710533329.8ACN109213978B (en)2017-07-032017-07-03Method and device for merging cells, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201710533329.8ACN109213978B (en)2017-07-032017-07-03Method and device for merging cells, electronic equipment and readable storage medium

Publications (2)

Publication NumberPublication Date
CN109213978A CN109213978A (en)2019-01-15
CN109213978Btrue CN109213978B (en)2022-05-06

Family

ID=64993425

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201710533329.8AActiveCN109213978B (en)2017-07-032017-07-03Method and device for merging cells, electronic equipment and readable storage medium

Country Status (1)

CountryLink
CN (1)CN109213978B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN109857662B (en)*2019-01-252022-09-27浙江数链科技有限公司Use case data processing method and device, computer equipment and storage medium
CN112528703B (en)*2019-09-172023-11-03珠海金山办公软件有限公司 A method, device and electronic equipment for identifying table structure
CN112784548B (en)*2019-11-072024-08-13珠海金山办公软件有限公司 A cell merging method, device, and storage medium
CN111444689B (en)*2020-06-172020-10-09广州市玄武无线科技股份有限公司Data-based table cell merging method and system
CN114218902A (en)*2021-11-152022-03-22北京金山办公软件股份有限公司 Form processing method, apparatus, electronic device, and computer-readable storage medium
CN116205204B (en)*2023-03-012023-08-04北京中宏立达科技发展有限公司Dynamic form merging method and system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
JP2002133360A (en)*2000-10-272002-05-10Mitsuyoshi YamaneLayout-based input/output method for cell in spreadsheet operation, and recording medium stored with program for the same
CN101388028A (en)*2008-09-192009-03-18金蝶软件(中国)有限公司Method and apparatus for combining cells
US8954838B2 (en)*2009-12-042015-02-10Synopsys, Inc.Presenting data in a tabular format
US8433714B2 (en)*2010-05-272013-04-30Business Objects Software Ltd.Data cell cluster identification and table transformation
CN104142932A (en)*2013-05-072014-11-12苏州精易会信息技术有限公司Method for displaying sub table borders of webpage spreadsheet
CN104391833A (en)*2014-12-052015-03-04张明兴Automation for transverse typesetting, header forming and parallelization for table making software

Also Published As

Publication numberPublication date
CN109213978A (en)2019-01-15

Similar Documents

PublicationPublication DateTitle
CN109213978B (en)Method and device for merging cells, electronic equipment and readable storage medium
CN111639473A (en)Excel file analysis method and device based on java, computer equipment and storage medium
JP2014510963A (en) Associating captured image data with a spreadsheet
CN107369090A (en)Open an account generation method, equipment and the computer-readable recording medium of the page
CN111414727B (en) A method, device and electronic device for editing header and footer of PDF document
CN109753641A (en) A method, device, electronic device and storage medium for changing the position of an object
CN101976394A (en)Data acquiring and counting system and method
CN101201833A (en) PDF document data filling system and method
EP2009556A1 (en)Electronic table data processing method and system based on time sequences
CN112632929B (en)Method and device for intelligently recommending chart based on table data and electronic equipment
CN110619116A (en)Data processing method, device, terminal and storage medium
CN109992759B (en)Table object editing method and device, electronic equipment and storage medium
CN112949266B (en)Electronic form processing method, electronic form processing device, electronic equipment and storage medium
CN111832270B (en) A method, device and electronic equipment for displaying row numbers and column labels of tables in non-table documents
CN112784551A (en)Method, device and equipment for realizing cell and picture adaptation
CN110852045B (en)Method and device for deleting document content, electronic equipment and storage medium
CN112231111A (en) A data pasting method, device, electronic device and storage medium
CN112329409A (en) Cell color conversion method, device and electronic device
CN112784560B (en)Data display method and device
CN111783408A (en) Cell pasting method, device, electronic device and storage medium
CN101963892B (en)Method and device for printing table data
CN112329407B (en)Method and device for adding data in form of document and electronic equipment
CN111767699B (en) A cell processing method and device
CN112395829B (en) A method, device and electronic equipment for adding Chinese numbers to documents
CN111898344B (en)Method and device for pasting unit cell, electronic equipment and storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp