summaryrefslogtreecommitdiff
path: root/shape.go
diff options
context:
space:
mode:
Diffstat (limited to 'shape.go')
-rw-r--r--shape.go81
1 files changed, 47 insertions, 34 deletions
diff --git a/shape.go b/shape.go
index 2923763..99ab291 100644
--- a/shape.go
+++ b/shape.go
@@ -22,15 +22,6 @@ func parseFormatShapeSet(formatSet string) *formatShape {
XScale: 1.0,
YScale: 1.0,
},
- Font: formatFont{
- Bold: false,
- Italic: false,
- Underline: "none",
- Family: "Calibri",
- Size: 11,
- Color: "#000000",
- },
- Text: " ",
}
json.Unmarshal([]byte(formatSet), &format)
return &format
@@ -41,7 +32,7 @@ func parseFormatShapeSet(formatSet string) *formatShape {
// print settings) and properties set. For example, add text box (rect shape) in
// Sheet1:
//
-// xlsx.AddShape("Sheet1", "G6", `{"type":"rect", "text":"Rectangle Shape", "color":{"line":"#4286F4","fill":"#8eb9ff"}, "font":{"bold":true,"italic":true,"family":"Berlin Sans FB Demi","size":36,"color":"#777777","underline":"sng"}, "width": 180, "height": 90}`)
+// xlsx.AddShape("Sheet1", "G6", `{"type":"rect","color":{"line":"#4286F4","fill":"#8eb9ff"},"paragraph":[{"text":"Rectangle Shape","font":{"bold":true,"italic":true,"family":"Berlin Sans FB Demi","size":36,"color":"#777777","underline":"sng"}}],"width":180,"height": 90}`)
//
// The following shows the type of chart supported by excelize:
//
@@ -281,11 +272,6 @@ func (f *File) AddShape(sheet, cell, format string) {
// drawingXMLand format sets.
func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *formatShape) {
textUnderlineType := map[string]bool{"none": true, "words": true, "sng": true, "dbl": true, "heavy": true, "dotted": true, "dottedHeavy": true, "dash": true, "dashHeavy": true, "dashLong": true, "dashLongHeavy": true, "dotDash": true, "dotDashHeavy": true, "dotDotDash": true, "dotDotDashHeavy": true, "wavy": true, "wavyHeavy": true, "wavyDbl": true}
- u := formatSet.Font.Underline
- _, ok := textUnderlineType[u]
- if !ok {
- u = "none"
- }
cell = strings.ToUpper(cell)
fromCol := string(strings.Map(letterOnlyMapF, cell))
fromRow, _ := strconv.Atoi(strings.Map(intOnlyMapF, cell))
@@ -346,29 +332,56 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format
RtlCol: false,
Anchor: "t",
},
- P: &aP{
- R: &aR{
- RPr: aRPr{
- I: formatSet.Font.Italic,
- B: formatSet.Font.Bold,
- Lang: "en-US",
- AltLang: "en-US",
- U: u,
- Sz: formatSet.Font.Size * 100,
- Latin: &aLatin{Typeface: formatSet.Font.Family},
- SolidFill: &aSolidFill{
- SrgbClr: &attrValString{
- Val: strings.Replace(strings.ToUpper(formatSet.Font.Color), "#", "", -1),
- },
+ },
+ }
+ if len(formatSet.Paragraph) < 1 {
+ formatSet.Paragraph = []formatShapeParagraph{
+ {
+ Font: formatFont{
+ Bold: false,
+ Italic: false,
+ Underline: "none",
+ Family: "Calibri",
+ Size: 11,
+ Color: "#000000",
+ },
+ Text: " ",
+ },
+ }
+ }
+ for _, p := range formatSet.Paragraph {
+ u := p.Font.Underline
+ _, ok := textUnderlineType[u]
+ if !ok {
+ u = "none"
+ }
+ text := p.Text
+ if text == "" {
+ text = " "
+ }
+ paragraph := &aP{
+ R: &aR{
+ RPr: aRPr{
+ I: p.Font.Italic,
+ B: p.Font.Bold,
+ Lang: "en-US",
+ AltLang: "en-US",
+ U: u,
+ Sz: p.Font.Size * 100,
+ Latin: &aLatin{Typeface: p.Font.Family},
+ SolidFill: &aSolidFill{
+ SrgbClr: &attrValString{
+ Val: strings.Replace(strings.ToUpper(p.Font.Color), "#", "", -1),
},
},
- T: formatSet.Text,
- },
- EndParaRPr: &aEndParaRPr{
- Lang: "en-US",
},
+ T: text,
},
- },
+ EndParaRPr: &aEndParaRPr{
+ Lang: "en-US",
+ },
+ }
+ shape.TxBody.P = append(shape.TxBody.P, paragraph)
}
twoCellAnchor.Sp = &shape
twoCellAnchor.ClientData = &xdrClientData{