From 72d84c0cbdd0ad748dba19e21d4e92ea077110c7 Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 8 Sep 2021 22:05:42 +0800 Subject: This closes #262, support set line width of add the shape --- shape.go | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'shape.go') diff --git a/shape.go b/shape.go index e58d5cf..61322dd 100644 --- a/shape.go +++ b/shape.go @@ -32,6 +32,7 @@ func parseFormatShapeSet(formatSet string) (*formatShape, error) { XScale: 1.0, YScale: 1.0, }, + Line: formatLine{Width: 1}, } err := json.Unmarshal([]byte(formatSet), &format) return &format, err @@ -42,7 +43,33 @@ func parseFormatShapeSet(formatSet string) (*formatShape, error) { // print settings) and properties set. For example, add text box (rect shape) // in Sheet1: // -// err := f.AddShape("Sheet1", "G6", `{"type":"rect","color":{"line":"#4286F4","fill":"#8eb9ff"},"paragraph":[{"text":"Rectangle Shape","font":{"bold":true,"italic":true,"family":"Times New Roman","size":36,"color":"#777777","underline":"sng"}}],"width":180,"height": 90}`) +// err := f.AddShape("Sheet1", "G6", `{ +// "type": "rect", +// "color": +// { +// "line": "#4286F4", +// "fill": "#8eb9ff" +// }, +// "paragraph": [ +// { +// "text": "Rectangle Shape", +// "font": +// { +// "bold": true, +// "italic": true, +// "family": "Times New Roman", +// "size": 36, +// "color": "#777777", +// "underline": "sng" +// } +// }], +// "width": 180, +// "height": 90, +// "line": +// { +// "width": 1.2 +// } +// }`) // // The following shows the type of shape supported by excelize: // @@ -378,6 +405,11 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format }, }, } + if formatSet.Line.Width != 1 { + shape.SpPr.Ln = xlsxLineProperties{ + W: f.ptToEMUs(formatSet.Line.Width), + } + } if len(formatSet.Paragraph) < 1 { formatSet.Paragraph = []formatShapeParagraph{ { -- cgit v1.2.1