diff options
author | xuri <xuri.me@gmail.com> | 2020-05-14 22:36:00 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2020-05-14 22:36:00 +0800 |
commit | 9baa1bbc9865bee1b3c8981ab98eb8c9049c40e4 (patch) | |
tree | 2f6f90e73a7d6fc889ee4928e0a0152cf1cae1b0 /table.go | |
parent | dfea8f96edc326717822ec9c4b92f462d0fe1255 (diff) |
Fix #637, improve the compatibility of the auto filter with Office 2007 - 2013
Diffstat (limited to 'table.go')
-rw-r--r-- | table.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -290,6 +290,20 @@ func (f *File) AutoFilter(sheet, hcell, vcell, format string) error { return err } ref := cellStart + ":" + cellEnd + wb := f.workbookReader() + d := xlsxDefinedName{ + Name: "_xlnm._FilterDatabase", + Hidden: true, + LocalSheetID: intPtr(f.GetSheetIndex(sheet)), + Data: fmt.Sprintf("%s!%s", sheet, ref), + } + if wb.DefinedNames != nil { + wb.DefinedNames.DefinedName = append(wb.DefinedNames.DefinedName, d) + } else { + wb.DefinedNames = &xlsxDefinedNames{ + DefinedName: []xlsxDefinedName{d}, + } + } refRange := vcol - hcol return f.autoFilter(sheet, ref, refRange, hcol, formatSet) } |