From f6f14f507ee1adf4883cb1b12f27932a63afb286 Mon Sep 17 00:00:00 2001 From: three Date: Fri, 13 Aug 2021 01:32:44 +0800 Subject: Speed up merge cells --- adjust.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'adjust.go') diff --git a/adjust.go b/adjust.go index 1fe6663..9f2176f 100644 --- a/adjust.go +++ b/adjust.go @@ -145,7 +145,7 @@ func (f *File) adjustAutoFilter(ws *xlsxWorksheet, dir adjustDirection, num, off return nil } - coordinates, err := f.areaRefToCoordinates(ws.AutoFilter.Ref) + coordinates, err := areaRefToCoordinates(ws.AutoFilter.Ref) if err != nil { return err } @@ -199,7 +199,7 @@ func (f *File) adjustMergeCells(ws *xlsxWorksheet, dir adjustDirection, num, off for i := 0; i < len(ws.MergeCells.Cells); i++ { areaData := ws.MergeCells.Cells[i] - coordinates, err := f.areaRefToCoordinates(areaData.Ref) + coordinates, err := areaRefToCoordinates(areaData.Ref) if err != nil { return err } @@ -219,7 +219,7 @@ func (f *File) adjustMergeCells(ws *xlsxWorksheet, dir adjustDirection, num, off x1 = f.adjustMergeCellsHelper(x1, num, offset) x2 = f.adjustMergeCellsHelper(x2, num, offset) } - if x1 == x2 && y1 == y2 { + if x1 == x2 && y1 == y2 && i >= 0 { f.deleteMergeCell(ws, i) i-- } @@ -234,7 +234,7 @@ func (f *File) adjustMergeCells(ws *xlsxWorksheet, dir adjustDirection, num, off // compare and calculate cell axis by the given pivot, operation axis and // offset. func (f *File) adjustMergeCellsHelper(pivot, num, offset int) int { - if pivot >= num { + if pivot > num { pivot += offset if pivot < 1 { return 1 -- cgit v1.2.1