xmlComments.go 3.4 KB

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