diff --git a/lib.go b/lib.go index 0223d9cd..22164d29 100644 --- a/lib.go +++ b/lib.go @@ -863,6 +863,7 @@ func readSheetsFromZipFile(f *zip.File, file *File, sheetXMLMap map[string]strin sb.WriteString(strconv.Itoa(sheet.Index)) sb.WriteString("} ") sb.WriteString(sheet.Error.Error()) + continue } sheetName := sheet.Sheet.Name sheetsByName[sheetName] = sheet.Sheet diff --git a/lib_test.go b/lib_test.go index 5b0a67df..1ee8271d 100644 --- a/lib_test.go +++ b/lib_test.go @@ -1364,6 +1364,13 @@ func TestLib(t *testing.T) { } }) + // Attempting to open a file with an invalid sheet name. + csRunO(c, "ReadFileWithInvalidSheet", func(c *qt.C, option FileOption) { + _, err := OpenFile("./testdocs/sheet_name_length_above_max.xlsx", option) + c.Assert(err, qt.Not(qt.IsNil)) + c.Assert(err.Error(), qt.Equals, "OpenFile: ReadZip: ReadZipReader: {SheetIndex: 0} readSheetFromFile: sheet name is invalid: sheet name must be 31 or fewer characters long. It is currently '32' characters long") + }) + } func TestReadRowsFromSheet(t *testing.T) { diff --git a/testdocs/sheet_name_length_above_max.xlsx b/testdocs/sheet_name_length_above_max.xlsx new file mode 100644 index 00000000..140e75c9 Binary files /dev/null and b/testdocs/sheet_name_length_above_max.xlsx differ