Fix #637, improve the compatibility of the auto filter with Office 2007 - 2013

This commit is contained in:
xuri 2020-05-14 22:36:00 +08:00
parent dfea8f96ed
commit 9baa1bbc98
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
1 changed files with 14 additions and 0 deletions

View File

@ -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)
}