xmlComments.go 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. Package excelize providing a set of functions that allow you to write to
  3. and read from XLSX files. Support reads and writes XLSX file generated by
  4. Microsoft Excel™ 2007 and later. Support save file without losing original
  5. charts of XLSX. This library needs Go version 1.8 or later.
  6. Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
  7. this source code is governed by a BSD-style license that can be found in
  8. the LICENSE file.
  9. */
  10. package excelize
  11. import "encoding/xml"
  12. // xlsxComments directly maps the comments element from the namespace
  13. // http://schemas.openxmlformats.org/spreadsheetml/2006/main. A comment is a
  14. // rich text note that is attached to and associated with a cell, separate from
  15. // other cell content. Comment content is stored separate from the cell, and is
  16. // displayed in a drawing object (like a text box) that is separate from, but
  17. // associated with, a cell. Comments are used as reminders, such as noting how a
  18. // complex formula works, or to provide feedback to other users. Comments can
  19. // also be used to explain assumptions made in a formula or to call out
  20. // something special about the cell.
  21. type xlsxComments struct {
  22. XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main comments"`
  23. Authors []xlsxAuthor `xml:"authors"`
  24. CommentList xlsxCommentList `xml:"commentList"`
  25. }
  26. // xlsxAuthor directly maps the author element. This element holds a string
  27. // representing the name of a single author of comments. Every comment shall
  28. // have an author. The maximum length of the author string is an implementation
  29. // detail, but a good guideline is 255 chars.
  30. type xlsxAuthor struct {
  31. Author string `xml:"author"`
  32. }
  33. // xlsxCommentList (List of Comments) directly maps the xlsxCommentList element.
  34. // This element is a container that holds a list of comments for the sheet.
  35. type xlsxCommentList struct {
  36. Comment []xlsxComment `xml:"comment"`
  37. }
  38. // xlsxComment directly maps the comment element. This element represents a
  39. // single user entered comment. Each comment shall have an author and can
  40. // optionally contain richly formatted text.
  41. type xlsxComment struct {
  42. Ref string `xml:"ref,attr"`
  43. AuthorID int `xml:"authorId,attr"`
  44. Text xlsxText `xml:"text"`
  45. }
  46. // xlsxText directly maps the text element. This element contains rich text
  47. // which represents the text of a comment. The maximum length for this text is a
  48. // spreadsheet application implementation detail. A recommended guideline is
  49. // 32767 chars.
  50. type xlsxText struct {
  51. R []xlsxR `xml:"r"`
  52. }
  53. // formatComment directly maps the format settings of the comment.
  54. type formatComment struct {
  55. Author string `json:"author"`
  56. Text string `json:"text"`
  57. }
  58. // Comment directly maps the comment information.
  59. type Comment struct {
  60. Author string `json:"author"`
  61. AuthorID int `json:"author_id"`
  62. Ref string `json:"ref"`
  63. Text string `json:"text"`
  64. }