mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-27 13:48:54 +08:00

This adds comment support for sheets. Excel requires a VML drawing with the comment box shape for each comment to display the comment. LibreOffice displays comments fine with or without the shape, and creates the shape for its own comments. For the sake of compatibility, we create comment shapes as well. I know of no other use for the legacy VML support other than comment boxes...
24 lines
520 B
Go
24 lines
520 B
Go
// Copyright 2017 Baliance. All rights reserved.
|
|
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"baliance.com/gooxml/spreadsheet"
|
|
)
|
|
|
|
func main() {
|
|
ss := spreadsheet.New()
|
|
sheet := ss.AddSheet()
|
|
|
|
sheet.Cell("A1").SetString("Hello World!")
|
|
sheet.Comments().AddCommentWithStyle("A1", "Gopher", "This looks interesting.")
|
|
sheet.Comments().AddCommentWithStyle("C10", "Gopher", "This is a different comment.")
|
|
|
|
if err := ss.Validate(); err != nil {
|
|
log.Fatalf("error validating sheet: %s", err)
|
|
}
|
|
|
|
ss.SaveToFile("comments.xlsx")
|
|
}
|