Fixed doc corruption when deleting all merged cells

This commit is contained in:
xuri 2019-08-03 23:10:01 +08:00
parent 9279c86d85
commit 1092009541
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
1 changed files with 5 additions and 2 deletions

View File

@ -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
}
}