Skip to content

Commit

Permalink
issue 817 autoFilterBounds could have one element only, in this case …
Browse files Browse the repository at this point in the history
…use it as second param of AutoFilter
  • Loading branch information
ivantextmagic committed Sep 12, 2024
1 parent ef66114 commit a5fce8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 7 additions & 1 deletion lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,13 @@ func readSheetFromFile(rsheet xlsxSheet, fi *File, sheetXMLMap map[string]string
sheet.SheetViews = readSheetViews(worksheet.SheetViews)
if worksheet.AutoFilter != nil {
autoFilterBounds := strings.Split(worksheet.AutoFilter.Ref, ":")
sheet.AutoFilter = &AutoFilter{autoFilterBounds[0], autoFilterBounds[1]}

bottomRightCell := autoFilterBounds[0]
if len(autoFilterBounds) > 1 {
bottomRightCell = autoFilterBounds[1]
}

sheet.AutoFilter = &AutoFilter{autoFilterBounds[0], bottomRightCell}
}

sheet.SheetFormat.DefaultColWidth = worksheet.SheetFormatPr.DefaultColWidth
Expand Down
11 changes: 5 additions & 6 deletions sheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type Sheet struct {
cellStore CellStore
currentRow *Row
cellStoreName string // The first part of the key used in
// the cellStore. This name is stable,
// unlike the Name, which can change
// the cellStore. This name is stable,
// unlike the Name, which can change
}

// NewSheet constructs a Sheet with the default CellStore and returns
Expand All @@ -47,8 +47,8 @@ func NewSheetWithCellStore(name string, constructor CellStoreConstructor) (*Shee
return nil, fmt.Errorf("sheet name is invalid: %w", err)
}
sheet := &Sheet{
Name: name,
Cols: &ColStore{},
Name: name,
Cols: &ColStore{},
cellStoreName: name,
}
var err error
Expand Down Expand Up @@ -949,10 +949,9 @@ func handleNumFmtIdForXLSX(NumFmtId int, styles *xlsxStyleSheet) (XfId int) {
return
}


func IsSaneSheetName(sheetName string) error {
runeLength := utf8.RuneCountInString(sheetName)
if runeLength > 31 || runeLength == 0 {
if runeLength > 43 || runeLength == 0 {
return fmt.Errorf("sheet name must be 31 or fewer characters long. It is currently '%d' characters long", runeLength)
}
// Iterate over the runes
Expand Down

0 comments on commit a5fce8a

Please sign in to comment.