diff options
author | xuri <xuri.me@gmail.com> | 2022-07-14 00:17:51 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2022-07-14 00:17:51 +0800 |
commit | e37724c22b95de974f0235e992236d555aa6ad12 (patch) | |
tree | 50cfee87bb0a5f928e85a1e5055c747b13ce0266 /sheetview.go | |
parent | a65c5846e45fece382f72465f9e858c788dfcfef (diff) |
This fix potential panic and file corrupted
- Fix the panic when set or get sheet view options on the sheet without views options
- Fix generated workbook corruption caused by empty created or modified dcterms in the document core properties
- Update the unit tests
Diffstat (limited to 'sheetview.go')
-rw-r--r-- | sheetview.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sheetview.go b/sheetview.go index bf8f023..99f0634 100644 --- a/sheetview.go +++ b/sheetview.go @@ -163,6 +163,11 @@ func (f *File) getSheetView(sheet string, viewIndex int) (*xlsxSheetView, error) if err != nil { return nil, err } + if ws.SheetViews == nil { + ws.SheetViews = &xlsxSheetViews{ + SheetView: []xlsxSheetView{{WorkbookViewID: 0}}, + } + } if viewIndex < 0 { if viewIndex < -len(ws.SheetViews.SheetView) { return nil, fmt.Errorf("view index %d out of range", viewIndex) |