From 1092009541430c711676efb95b876598f59bb53c Mon Sep 17 00:00:00 2001 From: xuri Date: Sat, 3 Aug 2019 23:10:01 +0800 Subject: [PATCH] Fixed doc corruption when deleting all merged cells --- adjust.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/adjust.go b/adjust.go index f26f132..ccc5ce9 100644 --- a/adjust.go +++ b/adjust.go @@ -54,6 +54,11 @@ func (f *File) adjustHelper(sheet string, dir adjustDirection, num, offset int) } checkSheet(xlsx) checkRow(xlsx) + + if xlsx.MergeCells != nil && len(xlsx.MergeCells.Cells) == 0 { + xlsx.MergeCells = nil + } + return nil } @@ -283,8 +288,6 @@ func (f *File) deleteMergeCell(sheet *xlsxWorksheet, idx int) { if len(sheet.MergeCells.Cells) > idx { sheet.MergeCells.Cells = append(sheet.MergeCells.Cells[:idx], sheet.MergeCells.Cells[idx+1:]...) sheet.MergeCells.Count = len(sheet.MergeCells.Cells) - } else { - sheet.MergeCells = nil } }