From 577a07f08c6121d627323db00fdf9e74989a5515 Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 3 Dec 2021 00:19:11 +0800 Subject: Simplify code and update unit test Improve unit test coverage for the functions: `NewStyle`, `SetActiveSheet`, `SearchSheet` and `deleteAndAdjustDefinedNames` Simplify code and add comments for the function: `deleteAndAdjustDefinedNames` --- sheet.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'sheet.go') diff --git a/sheet.go b/sheet.go index 6244e02..99ae1a2 100644 --- a/sheet.go +++ b/sheet.go @@ -586,15 +586,12 @@ func (f *File) DeleteSheet(name string) { f.SetActiveSheet(f.GetSheetIndex(activeSheetName)) } +// deleteAndAdjustDefinedNames delete and adjust defined name in the workbook +// by given worksheet ID. func deleteAndAdjustDefinedNames(wb *xlsxWorkbook, deleteLocalSheetID int) { - if wb == nil { + if wb == nil || wb.DefinedNames == nil { return } - - if wb.DefinedNames == nil { - return - } - for idx := 0; idx < len(wb.DefinedNames.DefinedName); idx++ { dn := wb.DefinedNames.DefinedName[idx] if dn.LocalSheetID != nil { -- cgit v1.2.1