xmlComments.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
  2. // this source code is governed by a BSD-style license that can be found in
  3. // the LICENSE file.
  4. //
  5. // Package excelize providing a set of functions that allow you to write to
  6. // and read from XLSX / XLSM / XLTM files. Supports reading and writing
  7. // spreadsheet documents generated by Microsoft Excel™ 2007 and later. Supports
  8. // complex components by high compatibility, and provided streaming API for
  9. // generating or reading data from a worksheet with huge amounts of data. This
  10. // library needs Go version 1.15 or later.
  11. package excelize
  12. import "encoding/xml"
  13. // xlsxComments directly maps the comments element from the namespace
  14. // http://schemas.openxmlformats.org/spreadsheetml/2006/main. A comment is a
  15. // rich text note that is attached to and associated with a cell, separate from
  16. // other cell content. Comment content is stored separate from the cell, and is
  17. // displayed in a drawing object (like a text box) that is separate from, but
  18. // associated with, a cell. Comments are used as reminders, such as noting how a
  19. // complex formula works, or to provide feedback to other users. Comments can
  20. // also be used to explain assumptions made in a formula or to call out
  21. // something special about the cell.
  22. type xlsxComments struct {
  23. XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main comments"`
  24. Authors []xlsxAuthor `xml:"authors"`
  25. CommentList xlsxCommentList `xml:"commentList"`
  26. }
  27. // xlsxAuthor directly maps the author element. This element holds a string
  28. // representing the name of a single author of comments. Every comment shall
  29. // have an author. The maximum length of the author string is an implementation
  30. // detail, but a good guideline is 255 chars.
  31. type xlsxAuthor struct {
  32. Author string `xml:"author"`
  33. }
  34. // xlsxCommentList (List of Comments) directly maps the xlsxCommentList element.
  35. // This element is a container that holds a list of comments for the sheet.
  36. type xlsxCommentList struct {
  37. Comment []xlsxComment `xml:"comment"`
  38. }
  39. // xlsxComment directly maps the comment element. This element represents a
  40. // single user entered comment. Each comment shall have an author and can
  41. // optionally contain richly formatted text.
  42. type xlsxComment struct {
  43. Ref string `xml:"ref,attr"`
  44. AuthorID int `xml:"authorId,attr"`
  45. Text xlsxText `xml:"text"`
  46. }
  47. // xlsxText directly maps the text element. This element contains rich text
  48. // which represents the text of a comment. The maximum length for this text is a
  49. // spreadsheet application implementation detail. A recommended guideline is
  50. // 32767 chars.
  51. type xlsxText struct {
  52. T *string `xml:"t"`
  53. R []xlsxR `xml:"r"`
  54. RPh *xlsxPhoneticRun `xml:"rPh"`
  55. PhoneticPr *xlsxPhoneticPr `xml:"phoneticPr"`
  56. }
  57. // xlsxPhoneticRun element represents a run of text which displays a phonetic
  58. // hint for this String Item (si). Phonetic hints are used to give information
  59. // about the pronunciation of an East Asian language. The hints are displayed
  60. // as text within the spreadsheet cells across the top portion of the cell.
  61. type xlsxPhoneticRun struct {
  62. Sb uint32 `xml:"sb,attr"`
  63. Eb uint32 `xml:"eb,attr"`
  64. T string `xml:"t"`
  65. }
  66. // formatComment directly maps the format settings of the comment.
  67. type formatComment struct {
  68. Author string `json:"author"`
  69. Text string `json:"text"`
  70. }
  71. // Comment directly maps the comment information.
  72. type Comment struct {
  73. Author string `json:"author"`
  74. AuthorID int `json:"author_id"`
  75. Ref string `json:"ref"`
  76. Text string `json:"text"`
  77. }