From b1c9884f6d186bd1bfb4fc1d34061856345b8530 Mon Sep 17 00:00:00 2001 From: Harris Date: Thu, 25 Apr 2019 11:24:25 -0500 Subject: Add the ability to change the default font Closes #390 --- shape.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shape.go') diff --git a/shape.go b/shape.go index c90963c..7dc7021 100644 --- a/shape.go +++ b/shape.go @@ -381,7 +381,7 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format Bold: false, Italic: false, Underline: "none", - Family: "Calibri", + Family: f.GetDefaultFont(), Size: 11, Color: "#000000", }, -- cgit v1.2.1 From 9c70d0ac868f66badf2663cc7b4b3c46d5411131 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 11 Aug 2019 00:36:14 +0800 Subject: Documentation updated, Go 1.10+ required --- shape.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shape.go') diff --git a/shape.go b/shape.go index 7dc7021..e3ed968 100644 --- a/shape.go +++ b/shape.go @@ -5,7 +5,7 @@ // Package excelize providing a set of functions that allow you to write to // and read from XLSX files. Support reads and writes XLSX file generated by // Microsoft Excelâ„¢ 2007 and later. Support save file without losing original -// charts of XLSX. This library needs Go version 1.8 or later. +// charts of XLSX. This library needs Go version 1.10 or later. package excelize -- cgit v1.2.1 From 407fb55c20a2524c4eccad9361120dee2a2719cd Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 21 Aug 2019 23:03:34 +0800 Subject: Update the Godoc --- shape.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shape.go') diff --git a/shape.go b/shape.go index e3ed968..8d95849 100644 --- a/shape.go +++ b/shape.go @@ -40,7 +40,7 @@ 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":"Berlin Sans FB Demi","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}`) // // The following shows the type of shape supported by excelize: // -- cgit v1.2.1 From 8922f659788187afa6d0a5d3248e999c2c1bb846 Mon Sep 17 00:00:00 2001 From: xuri Date: Mon, 16 Sep 2019 01:17:35 +0800 Subject: Combine functions: workBookRelsWriter, drawingRelsWriter into relsWriter; drawingRelsReader, workbookRelsReader, workSheetRelsReader into relsReader; addDrawingRelationships, addSheetRelationships into addRels --- shape.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'shape.go') diff --git a/shape.go b/shape.go index 8d95849..e6a2ff3 100644 --- a/shape.go +++ b/shape.go @@ -275,7 +275,9 @@ func (f *File) AddShape(sheet, cell, format string) error { drawingXML = strings.Replace(sheetRelationshipsDrawingXML, "..", "xl", -1) } else { // Add first shape for given sheet. - rID := f.addSheetRelationships(sheet, SourceRelationshipDrawingML, sheetRelationshipsDrawingXML, "") + name, _ := f.sheetMap[trimSheetName(sheet)] + sheetRels := "xl/worksheets/_rels/" + strings.TrimPrefix(name, "xl/worksheets/") + ".rels" + rID := f.addRels(sheetRels, SourceRelationshipDrawingML, sheetRelationshipsDrawingXML, "") f.addSheetDrawing(sheet, rID) } err = f.addDrawingShape(sheet, drawingXML, cell, formatSet) -- cgit v1.2.1 From eb520ae27757d4bca276fa2894bf461d75df9b37 Mon Sep 17 00:00:00 2001 From: xuri Date: Thu, 26 Sep 2019 22:28:14 +0800 Subject: Improve compatibility for charts --- shape.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'shape.go') diff --git a/shape.go b/shape.go index e6a2ff3..f284e43 100644 --- a/shape.go +++ b/shape.go @@ -411,11 +411,6 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format 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: text, }, @@ -423,6 +418,14 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format Lang: "en-US", }, } + srgbClr := strings.Replace(strings.ToUpper(p.Font.Color), "#", "", -1) + if len(srgbClr) == 6 { + paragraph.R.RPr.SolidFill = &aSolidFill{ + SrgbClr: &attrValString{ + Val: srgbClr, + }, + } + } shape.TxBody.P = append(shape.TxBody.P, paragraph) } twoCellAnchor.Sp = &shape -- cgit v1.2.1 From 4e4a5b9b3e052d1694442515492792fb1aa74c5a Mon Sep 17 00:00:00 2001 From: xuri Date: Mon, 23 Dec 2019 00:07:40 +0800 Subject: Improve compatibility, fix workbook's rels ID calc error --- shape.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'shape.go') diff --git a/shape.go b/shape.go index f284e43..2ea66ea 100644 --- a/shape.go +++ b/shape.go @@ -275,8 +275,7 @@ func (f *File) AddShape(sheet, cell, format string) error { drawingXML = strings.Replace(sheetRelationshipsDrawingXML, "..", "xl", -1) } else { // Add first shape for given sheet. - name, _ := f.sheetMap[trimSheetName(sheet)] - sheetRels := "xl/worksheets/_rels/" + strings.TrimPrefix(name, "xl/worksheets/") + ".rels" + sheetRels := "xl/worksheets/_rels/" + strings.TrimPrefix(f.sheetMap[trimSheetName(sheet)], "xl/worksheets/") + ".rels" rID := f.addRels(sheetRels, SourceRelationshipDrawingML, sheetRelationshipsDrawingXML, "") f.addSheetDrawing(sheet, rID) } @@ -362,7 +361,7 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format FontRef: &aFontRef{ Idx: "minor", SchemeClr: &attrValString{ - Val: "tx1", + Val: stringPtr("tx1"), }, }, }, @@ -422,7 +421,7 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format if len(srgbClr) == 6 { paragraph.R.RPr.SolidFill = &aSolidFill{ SrgbClr: &attrValString{ - Val: srgbClr, + Val: stringPtr(srgbClr), }, } } @@ -454,7 +453,7 @@ func setShapeRef(color string, i int) *aRef { return &aRef{ Idx: i, SrgbClr: &attrValString{ - Val: strings.Replace(strings.ToUpper(color), "#", "", -1), + Val: stringPtr(strings.Replace(strings.ToUpper(color), "#", "", -1)), }, } } -- cgit v1.2.1 From 09485b3f9f0aefc58d51462aed65c2416205c591 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 29 Dec 2019 16:02:31 +0800 Subject: Improve code coverage unit tests --- shape.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shape.go') diff --git a/shape.go b/shape.go index 2ea66ea..e9bdb42 100644 --- a/shape.go +++ b/shape.go @@ -1,4 +1,4 @@ -// Copyright 2016 - 2019 The excelize Authors. All rights reserved. Use of +// Copyright 2016 - 2020 The excelize Authors. All rights reserved. Use of // this source code is governed by a BSD-style license that can be found in // the LICENSE file. // -- cgit v1.2.1 From 9e2318cefa4ebaa7bf6b1dbc95b30ad7a32366b1 Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 10 Mar 2020 00:04:23 +0800 Subject: Resolve #470, export Style structs to allow create the style for cells by given JSON or structure --- shape.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shape.go') diff --git a/shape.go b/shape.go index e9bdb42..0455b22 100644 --- a/shape.go +++ b/shape.go @@ -378,7 +378,7 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format if len(formatSet.Paragraph) < 1 { formatSet.Paragraph = []formatShapeParagraph{ { - Font: formatFont{ + Font: Font{ Bold: false, Italic: false, Underline: "none", -- cgit v1.2.1