qax-os / excelize

Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets

Home Page:https://xuri.me/excelize

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue getting estyle from GetStyle function

devrodriguez opened this issue · comments

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.):

Is it exist other way for retrieve and modify some style, maybe I could use while issue is reviewed?

commented

Thanks for your issue. Could you show us a complete, standalone example program or reproducible demo? If you open an existing workbook, please provide the file attachment without confidential info.

issue_file.xlsx
Sure, above file its the issue file.
unfortunately I can't provide standalone example program.
I hope you can help me with the provided file.

thank you very much for your prompt response

On the other hand how can I understand what it mean propterty names like Lt1 Dk1 and others? Thks

commented

Thanks for your feedback. This issue has been fixed, please upgrade to the master branch code by go get -u github.com/xuri/excelize/v2@master, and this patch will be released in the next version. You can get more details about Lt1 and Dk1 in ISO/IEC 29500:1 (ECMA-376 OOXML) specification §20.1.4.1.22 and §20.1.4.1.9.

Thank you for your prompt response and implementation of the fix!