From c98fd7e5d05ee35d636304bb9864bb2943996c23 Mon Sep 17 00:00:00 2001 From: Wang Yaoshen Date: Fri, 14 Aug 2020 10:32:58 +0800 Subject: [PATCH] Fix issue #686 RemoveRow slice bounds out of range (#687) fix Hyperlinks update error --- adjust.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/adjust.go b/adjust.go index 226ea9e6..40898d9a 100644 --- a/adjust.go +++ b/adjust.go @@ -109,14 +109,15 @@ func (f *File) adjustHyperlinks(xlsx *xlsxWorksheet, sheet string, dir adjustDir // order is important if offset < 0 { - for rowIdx, linkData := range xlsx.Hyperlinks.Hyperlink { + for i := len(xlsx.Hyperlinks.Hyperlink) - 1; i >= 0; i-- { + linkData := xlsx.Hyperlinks.Hyperlink[i] colNum, rowNum, _ := CellNameToCoordinates(linkData.Ref) if (dir == rows && num == rowNum) || (dir == columns && num == colNum) { f.deleteSheetRelationships(sheet, linkData.RID) if len(xlsx.Hyperlinks.Hyperlink) > 1 { - xlsx.Hyperlinks.Hyperlink = append(xlsx.Hyperlinks.Hyperlink[:rowIdx], - xlsx.Hyperlinks.Hyperlink[rowIdx+1:]...) + xlsx.Hyperlinks.Hyperlink = append(xlsx.Hyperlinks.Hyperlink[:i], + xlsx.Hyperlinks.Hyperlink[i+1:]...) } else { xlsx.Hyperlinks = nil }