Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version compatibility issue: Unable to write any cells under golang 1.21.0. #1603

Closed
zhengkai opened this issue Aug 9, 2023 · 20 comments
Closed
Labels
duplicate This issue or pull request already exists

Comments

@zhengkai
Copy link

zhengkai commented Aug 9, 2023

Description

This morning, after an automatic upgrade to 1.21.0, I noticed that excelize is unable to write any cells, even using the examples from the official readme. The sheets, however, appear to be functioning normally. There are no error messages during the usage of SetCellValue and SaveAs, but the cell contents remain blank.

I didn't make any code changes; I simply replaced go build with go1.20.7 build and everything returned to normal.

Environment details (OS, Microsoft Excel™ version, physical, etc.):
Ubuntu 22.04
LibreOffice 7.3.7.2
Intel 9700K

@xuri
Copy link
Member

xuri commented Aug 9, 2023

Thanks for your issue. This was similar with #1465, #1595. There are some incompatible changes in the Go 1.21 encoding/xml library. I have given feedback to the Go team and created a patch for it, and still waiting for a reply. Please apply the patchsets in the CL https://go.dev/cl/466295 if you can.

@xuri xuri added the duplicate This issue or pull request already exists label Aug 9, 2023
@xijaja
Copy link

xijaja commented Aug 11, 2023

I just found this problem too。

@fifsky
Copy link

fifsky commented Aug 11, 2023

Is it compatible with go1.21? It will be a long time before the official merger. Projects that rely on excelize will not be able to use go1.21

@Desuuuu
Copy link

Desuuuu commented Aug 11, 2023

Removing the XMLName field from struct types that are not expected to have an explicit namespace seems to be a solution.

https://go.dev/play/p/z-acRVzkk6G

That should work as long as the type is not marshaled directly and its usage in other structs has the proper xml tag.

@xuri
Copy link
Member

xuri commented Aug 15, 2023

Hi @fifsky. I'll consider revendoring Go encoding/xml package in 1.16.15 (for backward compatible) in github.com/xuri/xml this week.

@fifsky
Copy link

fifsky commented Aug 15, 2023

Hi @fifsky. I'll consider revendoring Go encoding/xml package in 1.16.5 (for backward compatible) in github.com/xuri/xml this week.

OK, thank you for your reply

@xuri
Copy link
Member

xuri commented Aug 16, 2023

Hi @fifsky, I noticed that the Go team has added golang/go#62051 to the Go1.21.1 milestone, so I suggest waiting for the next minor releases, and you can vendoring the Go encoding/xml package by yourself if you need to.

@xuri
Copy link
Member

xuri commented Aug 16, 2023

Removing the XMLName field from struct types that are not expected to have an explicit namespace seems to be a solution.

https://go.dev/play/p/z-acRVzkk6G

That should work as long as the type is not marshaled directly and its usage in other structs has the proper xml tag.

Yeah, but we also need to marshal sub-type structs variable directly (such as marshal type variable B to XML element <b></b> in the example), in this case, still need type B has the proper xml.Name tag.

@fifsky
Copy link

fifsky commented Aug 16, 2023

@xuri I noticed that, too, thanks

@exfly
Copy link

exfly commented Aug 18, 2023

I just found this problem too。

@davidlam-winc
Copy link

davidlam-winc commented Aug 18, 2023

Got the same problem. This must the first time since my using Go, that I'm forced to go back a version! Hope that we don't end up needing to keep different versions of Go!

@fnickels
Copy link
Contributor

Hi @fifsky, I noticed that the Go team has added golang/go#62051 to the Go1.21.1 milestone, so I suggest waiting for the next minor releases, and you can vendoring the Go encoding/xml package by yourself if you need to.

What is involved in "vendoring the Go encoding/xml package"? Any pointers on how to attempt this? is this a simple change to the go.mod file, or some other process?

@xuri
Copy link
Member

xuri commented Aug 21, 2023

I have vendoring Go 1.16.15's encoding/xml package in github.com/xuri/xml, I will use it in the Excelize instead of encoding/xml standard library tomorrow, after that, you can upgrade the Excelize library with the master branch code, and these changes will be released in the next Excelize version, if Go 1.21.1 not yet released.

@xuri
Copy link
Member

xuri commented Aug 21, 2023

Since vendoring Go 1.16.15 encoding/xml will introduce security issues CVE-2022-28131 (fixed in the go1.18.4) and CVE-2022-30633 (fixed in the go1.18.10), so I suggest waiting for the next Go minor releases or vendoring Go 1.18.10 encoding/xml (made the Excelize require minimum Go version to Go 1.18).

@fifsky
Copy link

fifsky commented Aug 22, 2023

Agreed to upgrade the minimum version to go 1.18

@tomtwinkle
Copy link

@xuri
I'm using StreamWriter.
It seems to be working fine at the moment but does StreamWriter have the same problem?

@xuri
Copy link
Member

xuri commented Aug 23, 2023

@xuri
I'm using StreamWriter.
It seems to be working fine at the moment but does StreamWriter have the same problem?

Yes, I suggest using the Go 1.20.7 and previous Go released version or waiting for the next Go minor releases.

@xuri
Copy link
Member

xuri commented Sep 6, 2023

The Go 1.21.1 is released, this issue has been fixed.

@xuri xuri closed this as completed Sep 6, 2023
@xuri xuri unpinned this issue Sep 6, 2023
@Abzaek
Copy link

Abzaek commented Sep 9, 2024

Not working on "go version go1.22.6 linux/amd64" SaveAs and SetCellValue are not returning anything

@xuri
Copy link
Member

xuri commented Sep 9, 2024

Could you show us a complete, standalone example program or reproducible demo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

10 participants