tealeg / xlsx

Go library for reading and writing XLSX files.
Other
5.81k stars 810 forks source link

xlsxIndexedColors: index out of range #705

Closed sergeilem closed 3 years ago

sergeilem commented 3 years ago

Got an error on xlsx.OpenFile:

--- FAIL: BenchmarkOpenWithTealeg
    bench_test.go:64: error while opening file example.xlsm: OpenFile: ReadZip: ReadZipReader: readSheetsFromZipFile: runtime error: index out of range [64] with length 64
        goroutine 110 [running]:
        runtime/debug.Stack(0x0, 0x0, 0x0)
            C:/go/AppData/Local/go/src/runtime/debug/stack.go:24 +0xac
        github.com/tealeg/xlsx/v3.readSheetFromFile.func1(0xc0006c1f18)
            C:/go/go/pkg/mod/github.com/tealeg/xlsx/v3@v3.2.3/lib.go:691 +0x6d
        panic(0xa32040, 0xc0017e7098)
            C:/go/AppData/Local/go/src/runtime/panic.go:971 +0x4e6
        github.com/tealeg/xlsx/v3.(*xlsxColors).indexedColor(0xc000b270b0, 0x41, 0x0, 0x0)
            C:/go/go/pkg/mod/github.com/tealeg/xlsx/v3@v3.2.3/xmlStyle.go:1157 +0xb2
        github.com/tealeg/xlsx/v3.(*xlsxStyleSheet).argbValue(0xc000070840, 0x0, 0x0, 0x0, 0x0, 0xc0004d9380, 0x0, 0x0)
            C:/go/go/pkg/mod/github.com/tealeg/xlsx/v3@v3.2.3/xmlStyle.go:340 +0x14a
        github.com/tealeg/xlsx/v3.(*xlsxStyleSheet).populateStyleFromXf(0xc000070840, 0xc0005d7cc0, 0x1010000, 0x0, 0xc, 0x50, 0x0, 0xc0003d10d0, 0x0, 0x0, ...)
            C:/go/go/pkg/mod/github.com/tealeg/xlsx/v3@v3.2.3/xmlStyle.go:256 +0x42a
        github.com/tealeg/xlsx/v3.(*xlsxStyleSheet).getStyle(0xc000070840, 0x730, 0x0)
            C:/go/go/pkg/mod/github.com/tealeg/xlsx/v3@v3.2.3/xmlStyle.go:312 +0x2b9
        github.com/tealeg/xlsx/v3.readRowsFromSheet(0xc000086480, 0xc000106180, 0xc000dc32c0, 0xffffffffffffffff, 0xc001404000, 0x0, 0x0)
            C:/go/go/pkg/mod/github.com/tealeg/xlsx/v3@v3.2.3/lib.go:506 +0x6fd
        github.com/tealeg/xlsx/v3.readSheetFromFile(0xc000b5cd08, 0x14, 0xc000d34e40, 0x2, 0xc000d34e50, 0x5, 0x0, 0x0, 0xc000106180, 0xc0001bff50, ...)
            C:/go/go/pkg/mod/github.com/tealeg/xlsx/v3@v3.2.3/lib.go:715 +0x668
        github.com/tealeg/xlsx/v3.readSheetsFromZipFile.func2(0xc000b5cd08, 0x14, 0xc000d34e40, 0x2, 0xc000d34e50, 0x5, 0x0, 0x0, 0xc000106180, 0xc0001bff50, ...)
            C:/go/go/pkg/mod/github.com/tealeg/xlsx/v3@v3.2.3/lib.go:787 +0xa9
        created by github.com/tealeg/xlsx/v3.readSheetsFromZipFile
            C:/go/go/pkg/mod/github.com/tealeg/xlsx/v3@v3.2.3/lib.go:786 +0xd3f

There is indexed color 65 in the input file:

indexedColor65