summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart.go5
-rw-r--r--comment.go17
-rw-r--r--excelize_test.go8
3 files changed, 24 insertions, 6 deletions
diff --git a/chart.go b/chart.go
index d6f7fc0..ba428d5 100644
--- a/chart.go
+++ b/chart.go
@@ -168,10 +168,15 @@ func parseFormatChartSet(formatSet string) *formatChart {
// show_val
//
// show_bubble_size: Specifies the bubble size shall be shown in a data label. The show_bubble_size property is optional. The default value is false.
+//
// show_cat_name: Specifies that the category name shall be shown in the data label. The show_cat_name property is optional. The default value is true.
+//
// show_leader_lines: Specifies leader lines shall be shown for data labels. The show_leader_lines property is optional. The default value is false.
+//
// show_percent: Specifies that the percentage shall be shown in a data label. The show_percent property is optional. The default value is false.
+//
// show_series_name: Specifies that the series name shall be shown in a data label. The show_series_name property is optional. The default value is false.
+//
// show_val: Specifies that the value shall be shown in a data label. The show_val property is optional. The default value is false.
//
func (f *File) AddChart(sheet, cell, format string) {
diff --git a/comment.go b/comment.go
index 4919ae1..48a1654 100644
--- a/comment.go
+++ b/comment.go
@@ -19,10 +19,11 @@ func parseFormatCommentsSet(formatSet string) *formatComment {
}
// AddComment provides the method to add comment in a sheet by given worksheet
-// index, cell and format set (such as author and text). For example, add a
+// index, cell and format set (such as author and text). Note that the max
+// author length is 255 and the max text length is 32512. For example, add a
// comment in Sheet1!$A$30:
//
-// xlsx.AddComment("Sheet1", "A30", `{"author":"Excelize","text":"This is a comment."}`)
+// xlsx.AddComment("Sheet1", "A30", `{"author":"Excelize: ","text":"This is a comment."}`)
//
func (f *File) AddComment(sheet, cell, format string) {
formatSet := parseFormatCommentsSet(format)
@@ -147,6 +148,14 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
// addComment provides function to create chart as xl/comments%d.xml by given
// cell and format sets.
func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
+ a := formatSet.Author
+ t := formatSet.Text
+ if len(a) > 255 {
+ a = a[0:255]
+ }
+ if len(t) > 32512 {
+ t = t[0:32512]
+ }
comments := xlsxComments{
Authors: []xlsxAuthor{
xlsxAuthor{
@@ -169,7 +178,7 @@ func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
RFont: &attrValString{Val: "Calibri"},
Family: &attrValInt{Val: 2},
},
- T: formatSet.Author + ": ",
+ T: a,
},
xlsxR{
RPr: &xlsxRPr{
@@ -180,7 +189,7 @@ func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
RFont: &attrValString{Val: "Calibri"},
Family: &attrValInt{Val: 2},
},
- T: formatSet.Text,
+ T: t,
},
},
},
diff --git a/excelize_test.go b/excelize_test.go
index 38c299d..a5cc657 100644
--- a/excelize_test.go
+++ b/excelize_test.go
@@ -529,8 +529,12 @@ func TestAddComments(t *testing.T) {
if err != nil {
t.Log(err)
}
- xlsx.AddComment("Sheet1", "A30", `{"author":"Excelize","text":"This is first comment."}`)
- xlsx.AddComment("Sheet2", "B7", `{"author":"Excelize","text":"This is second comment."}`)
+ var s = "c"
+ for i := 0; i < 32767; i++ {
+ s += "c"
+ }
+ xlsx.AddComment("Sheet1", "A30", `{"author":"`+s+`","text":"`+s+`"}`)
+ xlsx.AddComment("Sheet2", "B7", `{"author":"Excelize: ","text":"This is a comment."}`)
err = xlsx.Save()
if err != nil {
t.Log(err)