From e37724c22b95de974f0235e992236d555aa6ad12 Mon Sep 17 00:00:00 2001 From: xuri Date: Thu, 14 Jul 2022 00:17:51 +0800 Subject: 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 --- sheetview.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sheetview.go') 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) -- cgit v1.2.1