diff options
author | xuri <xuri.me@gmail.com> | 2020-11-23 00:01:06 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2020-11-23 00:01:06 +0800 |
commit | 13e0ed2a69af0ff0ba20e50fb23dd4909a39b69d (patch) | |
tree | 9401dc111df1d36ae924fd82ecb35e442ca7b5e7 /sheet.go | |
parent | 599a8cb0bceb6cb14d3018360bb4c5140753c2b3 (diff) |
Fixed #735, refresh active tab after delete sheet
Diffstat (limited to 'sheet.go')
-rw-r--r-- | sheet.go | 12 |
1 files changed, 3 insertions, 9 deletions
@@ -317,7 +317,7 @@ func (f *File) GetActiveSheetIndex() (index int) { return } -// getActiveSheetID provides a function to get active sheet index of the +// getActiveSheetID provides a function to get active sheet ID of the // spreadsheet. If not found the active sheet will be return integer 0. func (f *File) getActiveSheetID() int { wb := f.workbookReader() @@ -499,6 +499,7 @@ func (f *File) DeleteSheet(name string) { sheetName := trimSheetName(name) wb := f.workbookReader() wbRels := f.relsReader(f.getWorkbookRelsPath()) + activeSheetName := f.GetSheetName(f.GetActiveSheetIndex()) for idx, sheet := range wb.Sheets.Sheet { if sheet.Name == sheetName { wb.Sheets.Sheet = append(wb.Sheets.Sheet[:idx], wb.Sheets.Sheet[idx+1:]...) @@ -526,14 +527,7 @@ func (f *File) DeleteSheet(name string) { f.SheetCount-- } } - if wb.BookViews != nil { - for idx, bookView := range wb.BookViews.WorkBookView { - if bookView.ActiveTab >= f.SheetCount { - wb.BookViews.WorkBookView[idx].ActiveTab-- - } - } - } - f.SetActiveSheet(len(f.GetSheetMap())) + f.SetActiveSheet(f.GetSheetIndex(activeSheetName)) } // deleteSheetFromWorkbookRels provides a function to remove worksheet |