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

SetRow of Stream Writer breaks file with special xml characters like & #1391

Closed
eaglexiang opened this issue Nov 15, 2022 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@eaglexiang
Copy link
Contributor

eaglexiang commented Nov 15, 2022

Description

SetRow of Stream Writer breaks file with special xml characters like &

Steps to reproduce the issue:

  1. Create new Stream Writer with any file
  2. write string contains & with SetRow
  3. Save

demo:

package main

import "github.com/xuri/excelize/v2"

func main() {
	f := excelize.NewFile()

	s, err := f.NewStreamWriter("Sheet1")
	if err != nil {
		panic(err)
	}

	err = s.SetRow("A1", []interface{}{"包含&"})
	if err != nil {
		panic(err)
	}

	err = f.SaveAs("test.xlsx")
	if err != nil {
		panic(err)
	}
}

Describe the results you received:

File Built:

image

image

Describe the results you expected:

marshal & into &amp.

image

https://www.educba.com/xml-special-characters/

Output of go version:

go version go1.19.1 windows/amd64

Excelize version or commit ID:

v2.6.1

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

@eaglexiang eaglexiang changed the title SetRow of Stream Writer cannot write special characters like & needing xml marshal. SetRow of Stream Writer breaks file with special xml characters like & Nov 15, 2022
@xuri xuri added bug Something isn't working in progress Working in progress labels Nov 15, 2022
@xuri xuri closed this as completed in 45d168c Nov 15, 2022
xuri added a commit to renxiaotu/excelize that referenced this issue Nov 15, 2022
…file

- Update and improve unit test coverage
@xuri
Copy link
Member

xuri commented Nov 15, 2022

Thanks for your issue, I have fixed it. Please upgrade to the master branch code, and this patch will be released in the next version.

@xuri xuri removed the in progress Working in progress label Nov 15, 2022
xuri added a commit that referenced this issue Nov 21, 2022
xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
…file

- Update and improve unit test coverage
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…file

- Update and improve unit test coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants