如題,測試代碼如下:
Sub MergeTest
Dim oCell 'Holds a cell temporarily
Dim oRange 'The primary range
Dim oSheet 'The fourth sheet
oSheet = ThisComponent.getSheets().getByIndex(0)
oRange = oSheet.getCellRangeByName("B2:D7")
oRange.merge(True)
Print "Range merged = " & oRange.isMerged() ' True
REM Now obtain a cell that was merged
REM and I can do it!
oCell = oSheet.getCellByPosition(2, 3) 'C4
Print "Cell C4 merged = " & oCell.isMerged() ' False
oCell = oSheet.getCellByPosition(1, 1) 'B2
Print "Cell B2 merged = " & oCell.isMerged() ' True
oCell.merge(False)
End Sub
只有開始的單元格B2,它的isMerged為true!
C4是在合并的單元格里面,但是他的isMerged為False?怎么判斷它在合并單元格里面呢?