diff options
author | xuri <xuri.me@gmail.com> | 2019-09-24 21:53:19 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2019-09-24 21:53:19 +0800 |
commit | a34d3b8c86d67d3ad0bc0dbedb69d3b4ebbc210f (patch) | |
tree | b281ae447cdf2f9355cde1d04098db664882a759 /col.go | |
parent | 75d66a03f33f25c29167c5f75ee8a4cc58598420 (diff) |
Compatibility improvement
Diffstat (limited to 'col.go')
-rw-r--r-- | col.go | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -10,6 +10,7 @@ package excelize import ( + "errors" "math" "strings" ) @@ -112,19 +113,22 @@ func (f *File) GetColOutlineLevel(sheet, col string) (uint8, error) { for c := range xlsx.Cols.Col { colData := &xlsx.Cols.Col[c] if colData.Min <= colNum && colNum <= colData.Max { - level = colData.OutlineLevel + level = colData.OutlineLevel + 1 } } return level, err } // SetColOutlineLevel provides a function to set outline level of a single -// column by given worksheet name and column name. For example, set outline -// level of column D in Sheet1 to 2: +// column by given worksheet name and column name. The value of parameter +// 'level' is 1-7. For example, set outline level of column D in Sheet1 to 2: // // err := f.SetColOutlineLevel("Sheet1", "D", 2) // func (f *File) SetColOutlineLevel(sheet, col string, level uint8) error { + if level > 7 || level < 1 { + return errors.New("invalid outline level") + } colNum, err := ColumnNameToNumber(col) if err != nil { return err |