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

AddComment only save then first author #830

Closed
raochq opened this issue Apr 26, 2021 · 1 comment
Closed

AddComment only save then first author #830

raochq opened this issue Apr 26, 2021 · 1 comment
Labels
confirmed This issue can be reproduced

Comments

@raochq
Copy link
Contributor

raochq commented Apr 26, 2021

copy comments with different authors, it only save the first author.

test code:

func testCopyComment() {
	f1 := excelize.NewFile()
	f1.AddComment("Sheet1", "A1", `{"author":"AA","text":" comment 1"}`)
	f1.AddComment("Sheet1", "A2", `{"author":"BB","text":" comment 2"}`)
	comment1 := f1.GetComments()["Sheet1"]

	fmt.Printf("%+v\n", comment1)
	f2 := excelize.NewFile()
	for _, com := range comment1 {
		f2.AddComment("Sheet1", com.Ref, fmt.Sprintf(`{"author":"%s","text":"%s"}`, com.Author, strings.TrimPrefix(com.Text, com.Author)))
	}
	comment2 := f2.GetComments()["Sheet1"]
	fmt.Printf("%+v\n", comment2)
}

output:

[{Author:AA AuthorID:0 Ref:A1 Text:AA comment 1} {Author:AA AuthorID:0 Ref:A2 Text:BB comment 2}]
[{Author:AA AuthorID:0 Ref:A1 Text:AA comment 1} {Author:AA AuthorID:0 Ref:A2 Text:AABB comment 2}]

@xuri xuri added confirmed This issue can be reproduced in progress Working in progress labels Apr 27, 2021
@xuri xuri closed this as completed in a13ef55 Apr 27, 2021
@xuri
Copy link
Member

xuri commented Apr 27, 2021

Thanks for your feedback, I have fixed it, please try to use the master branch code, and this patch will be released in the next version.

@xuri xuri removed the in progress Working in progress label Apr 27, 2021
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…ue when get and add comments on multi authors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed This issue can be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants