This commit is contained in:
parent
7b3dd03947
commit
284345e471
|
@ -618,6 +618,7 @@ func (f *File) adjustMergeCells(ws *xlsxWorksheet, sheet string, dir adjustDirec
|
|||
if dir == rows {
|
||||
if y1 == num && y2 == num && offset < 0 {
|
||||
f.deleteMergeCell(ws, i)
|
||||
i--
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -625,6 +626,7 @@ func (f *File) adjustMergeCells(ws *xlsxWorksheet, sheet string, dir adjustDirec
|
|||
} else {
|
||||
if x1 == num && x2 == num && offset < 0 {
|
||||
f.deleteMergeCell(ws, i)
|
||||
i--
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -644,8 +646,8 @@ func (f *File) adjustMergeCells(ws *xlsxWorksheet, sheet string, dir adjustDirec
|
|||
}
|
||||
|
||||
// adjustMergeCellsHelper provides a function for adjusting merge cells to
|
||||
// compare and calculate cell reference by the given pivot, operation reference and
|
||||
// offset.
|
||||
// compare and calculate cell reference by the given pivot, operation reference
|
||||
// and offset.
|
||||
func (f *File) adjustMergeCellsHelper(p1, p2, num, offset int) (int, int) {
|
||||
if p2 < p1 {
|
||||
p1, p2 = p2, p1
|
||||
|
|
|
@ -353,6 +353,15 @@ func TestRemoveRow(t *testing.T) {
|
|||
assert.NoError(t, f.RemoveRow(sheet1, 10))
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestRemoveRow.xlsx")))
|
||||
|
||||
f = NewFile()
|
||||
assert.NoError(t, f.MergeCell("Sheet1", "A1", "C1"))
|
||||
assert.NoError(t, f.MergeCell("Sheet1", "A2", "C2"))
|
||||
assert.NoError(t, f.RemoveRow("Sheet1", 1))
|
||||
mergedCells, err := f.GetMergeCells("Sheet1")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "A1", mergedCells[0].GetStartAxis())
|
||||
assert.Equal(t, "C1", mergedCells[0].GetEndAxis())
|
||||
|
||||
// Test remove row on not exist worksheet
|
||||
assert.EqualError(t, f.RemoveRow("SheetN", 1), "sheet SheetN does not exist")
|
||||
// Test remove row with invalid sheet name
|
||||
|
|
Loading…
Reference in New Issue