Skip to content

Issue getting estyle from GetStyle function #1963

Closed
@devrodriguez

Description

@devrodriguez

Description
Im getting invalid memory address or nil pointer dereference when use GetStyle() > extractFills() functions, looks like if some background style does not set

Steps to reproduce the issue:

  1. It is not clear yet when is the problem come, user upload a modified file and the problem comes with the file
  2. I use file.GetStyle() function, I traced the error to GetBaseColor() function line:1385
  3. I get the below stack trace:
runtime error: invalid memory address or nil pointer dereference
        runtime.gopanic
		/usr/lib/go/src/runtime/panic.go:914
	runtime.panicmem
		/usr/lib/go/src/runtime/panic.go:261
	runtime.sigpanic
		/usr/lib/go/src/runtime/signal_unix.go:861
	github.com/xuri/excelize/v2.(*File).GetBaseColor
		/go/pkg/mod/github.com/xuri/excelize/**@v2.8.1/styles.go:1385
	github.com/xuri/excelize/v2.(*File).getThemeColor
		/go/pkg/mod/github.com/xuri/excelize/**@v2.8.1/styles.go:1422
	github.com/xuri/excelize/v2.(*File).extractFills
		/go/pkg/mod/github.com/xuri/excelize/**@v2.8.1/styles.go:1488
	github.com/xuri/excelize/v2.(*File).GetStyle
		/go/pkg/mod/github.com/xuri/excelize/**@v2.8.1/styles.go:1614
	github.com/melisource/fury_shipping-claims-backoffice/pkg/fprocess.ResetCellStyle
		/app/pkg/fprocess/fprocess.go:446

image
image

On above screenshots I can see that clrScheme.Lt1.SysClr is nil then when it try to get LastClr get panic.
Then my question is, Why SysClr is nil and what that it mean?

Describe the results you received:
invalid memory address or nil pointer dereference

Describe the results you expected:
Stye by index provided

Output of go version:

go version go1.21.6 darwin/arm64

Excelize version or commit ID:

v2.8.1

Environment details (OS, Microsoft Excel™ version, physical, etc.):

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions