diff options
author | xuri <xuri.me@gmail.com> | 2021-07-15 23:24:01 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2021-07-15 23:24:01 +0800 |
commit | fbcfdeae90b7e755a70c6ceef27346c7d0552937 (patch) | |
tree | 4657475eb0400a8aa2e0259b6555cb1d771792b3 | |
parent | f62c45fe0c111774fc69a31a42d5f3add10e5095 (diff) |
This closes #879, fix delete defined name failed in some case
-rw-r--r-- | sheet.go | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1520,11 +1520,15 @@ func (f *File) DeleteDefinedName(definedName *DefinedName) error { wb := f.workbookReader() if wb.DefinedNames != nil { for idx, dn := range wb.DefinedNames.DefinedName { - var scope string + scope := "Workbook" + deleteScope := definedName.Scope + if deleteScope == "" { + deleteScope = "Workbook" + } if dn.LocalSheetID != nil { scope = f.GetSheetName(*dn.LocalSheetID) } - if scope == definedName.Scope && dn.Name == definedName.Name { + if scope == deleteScope && dn.Name == definedName.Name { wb.DefinedNames.DefinedName = append(wb.DefinedNames.DefinedName[:idx], wb.DefinedNames.DefinedName[idx+1:]...) return nil } |