diff --git a/excelize_test.go b/excelize_test.go index 634364d..292b358 100644 --- a/excelize_test.go +++ b/excelize_test.go @@ -34,7 +34,7 @@ func TestExcelize(t *testing.T) { // Test completion column. f1.SetCellValue("Sheet2", "M2", nil) // Test read cell value with given axis large than exists row. - f1.GetCellValue("Sheet2", "E13") + f1.GetCellValue("Sheet2", "E231") for i := 1; i <= 300; i++ { f1.SetCellStr("SHEET3", "c"+strconv.Itoa(i), strconv.Itoa(i)) @@ -78,6 +78,13 @@ func TestExcelize(t *testing.T) { t.Log(err) } + // Test set active sheet without BookViews and Sheets maps in xl/workbook.xml. + f4, err := OpenFile("./test/badWorkbook.xlsx") + f4.SetActiveSheet(2) + if err != nil { + t.Log(err) + } + // Test open a XLSX file with given illegal path. _, err = OpenFile("./test/Workbook.xlsx") if err != nil { diff --git a/sheet.go b/sheet.go index 66a72f5..c0e9287 100644 --- a/sheet.go +++ b/sheet.go @@ -42,7 +42,7 @@ func (f *File) setContentTypes(index int) { // Update sheet property by given index. func (f *File) setSheet(index int) { var xlsx xlsxWorksheet - xlsx.Dimension.Ref = "A1" + xlsx.Dimension.Ref = `A1` xlsx.SheetViews.SheetView = append(xlsx.SheetViews.SheetView, xlsxSheetView{ WorkbookViewID: 0, }) @@ -85,7 +85,7 @@ func (f *File) addXlsxWorkbookRels(sheet int) { content := f.readXlsxWorkbookRels() rID := len(content.Relationships) + 1 ID := bytes.Buffer{} - ID.WriteString("rId") + ID.WriteString(`rId`) ID.WriteString(strconv.Itoa(rID)) target := bytes.Buffer{} target.WriteString(`worksheets/sheet`) diff --git a/test/badWorkbook.xlsx b/test/badWorkbook.xlsx new file mode 100644 index 0000000..f917a20 Binary files /dev/null and b/test/badWorkbook.xlsx differ