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

add comment without author #1204

Closed
d3zn opened this issue Apr 19, 2022 · 3 comments
Closed

add comment without author #1204

d3zn opened this issue Apr 19, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@d3zn
Copy link

d3zn commented Apr 19, 2022

Description
author参数设置为空字符串时 ,打开excel提示 “部分内容有问题。是否让我们尽量尝试恢复? ...”
When the author parameter is set to an empty string, opening excel prompts "There is a problem with some content. Let's try to restore it as much as possible? ..." (google translate)

code

f := excelize.NewFile()
sheet := "Sheet1"
_ = f.SetCellStr(sheet, "A1", "value")
f.AddComment(sheet, "A1", fmt.Sprintf(`{"author":"", "text":"%s"}`, "value comment"))
f.SaveAs("test.xlsx")

Output of go version:

1.16.5

Excelize version or commit ID:

2.6.0

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

macOS BigSur 11.5.2  Microsoft Excel for Mac version 16.59 (22031300) Microsoft 365
@d3zn
Copy link
Author

d3zn commented Apr 19, 2022

Excel comments have a default author: Author: value comment when use fmt.Sprintf(`{"text":"%s"}`, "value comment"), but i dont need
So now,i have to use the author as text

@xuri
Copy link
Member

xuri commented Apr 19, 2022

Thanks for your issue. The author will show with bold style in the comments box currently. I'll consider adding support for creating rich text comments later.

@xuri xuri added the enhancement New feature or request label Apr 19, 2022
@xuri xuri closed this as completed in 0b42be9 Nov 2, 2022
xuri added a commit that referenced this issue Nov 2, 2022
- Allowing insert SVG format images
- Unit tests updated
@xuri
Copy link
Member

xuri commented Nov 2, 2022

I have added support for creating rich text comments. This feature will be released in version 2.7.0, this is a breaking change, now you can add a comment like this:

err := f.AddComment(sheet, excelize.Comment{
    Cell:   "A12",
    Author: "Excelize",
    Text:   "Excelize: This is a comment.",
})

or set rich text in the comment

err := f.AddComment(sheet, excelize.Comment{
    Cell:   "A12",
    Author: "Excelize",
    Runs:   []excelize.RichTextRun{
        {Text: "Excelize: ", Font: &excelize.Font{Bold: true}},
        {Text: "This is a comment."},
    },
})

xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
- Allowing insert SVG format images
- Unit tests updated
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
- Allowing insert SVG format images
- Unit tests updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants