From d08a6d243761a6214f8fef3181b689251bb72de0 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 21 Mar 2021 19:39:36 -0400 Subject: [PATCH] updated SetDefinedName's localSheetId attr to use sheetIndex Excelize 2.3.2 OUT: ``` ap-T-QP-11!$2:$5 R-T-QP-11!$2:$13 ``` MS Excel 2010 out ``` 'ap-T-QP-11'!$2:$5 'R-T-QP-11'!$2:$13 ``` Compare localSheetId it uses sheet index instead of sheet's sheetId --- sheet.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sheet.go b/sheet.go index 08736447..5a9fd46e 100644 --- a/sheet.go +++ b/sheet.go @@ -1487,9 +1487,8 @@ func (f *File) SetDefinedName(definedName *DefinedName) error { Data: definedName.RefersTo, } if definedName.Scope != "" { - if sheetID := f.getSheetID(definedName.Scope); sheetID != 0 { - sheetID-- - d.LocalSheetID = &sheetID + if sheetIndex := f.GetSheetIndex(definedName.Scope); sheetIndex >= 0 { + d.LocalSheetID = &sheetIndex } } if wb.DefinedNames != nil {