diff options
author | xuri <xuri.me@gmail.com> | 2020-12-22 08:47:46 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2020-12-22 01:48:52 +0000 |
commit | 576bfffbe6add78e719fc4fab851f40f5779a4d3 (patch) | |
tree | 74df6f7609e34aa9b46f3d19111a44c3bdacf229 /README.md | |
parent | 77978ac68d3808060e58df41ebede4b9f3631641 (diff) |
This closes #752, fix incorrectly merged cells on duplicate row, and new formula function: LOWER, PROPER, UPPER
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 43 |
1 files changed, 37 insertions, 6 deletions
@@ -97,7 +97,7 @@ func main() { ### Add chart to spreadsheet file -With Excelize chart generation and management is as easy as a few lines of code. You can build charts based off data in your worksheet or generate charts without any data in your worksheet at all. +With Excelize chart generation and management is as easy as a few lines of code. You can build charts based on data in your worksheet or generate charts without any data in your worksheet at all. <p align="center"><img width="650" src="./test/images/chart.png" alt="Excelize"></p> @@ -111,8 +111,10 @@ import ( ) func main() { - categories := map[string]string{"A2": "Small", "A3": "Normal", "A4": "Large", "B1": "Apple", "C1": "Orange", "D1": "Pear"} - values := map[string]int{"B2": 2, "C2": 3, "D2": 3, "B3": 5, "C3": 2, "D3": 4, "B4": 6, "C4": 7, "D4": 8} + categories := map[string]string{ + "A2": "Small", "A3": "Normal", "A4": "Large", "B1": "Apple", "C1": "Orange", "D1": "Pear"} + values := map[string]int{ + "B2": 2, "C2": 3, "D2": 3, "B3": 5, "C3": 2, "D3": 4, "B4": 6, "C4": 7, "D4": 8} f := excelize.NewFile() for k, v := range categories { f.SetCellValue("Sheet1", k, v) @@ -120,7 +122,29 @@ func main() { for k, v := range values { f.SetCellValue("Sheet1", k, v) } - if err := f.AddChart("Sheet1", "E1", `{"type":"col3DClustered","series":[{"name":"Sheet1!$A$2","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$2:$D$2"},{"name":"Sheet1!$A$3","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$3:$D$3"},{"name":"Sheet1!$A$4","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$4:$D$4"}],"title":{"name":"Fruit 3D Clustered Column Chart"}}`); err != nil { + if err := f.AddChart("Sheet1", "E1", `{ + "type": "col3DClustered", + "series": [ + { + "name": "Sheet1!$A$2", + "categories": "Sheet1!$B$1:$D$1", + "values": "Sheet1!$B$2:$D$2" + }, + { + "name": "Sheet1!$A$3", + "categories": "Sheet1!$B$1:$D$1", + "values": "Sheet1!$B$3:$D$3" + }, + { + "name": "Sheet1!$A$4", + "categories": "Sheet1!$B$1:$D$1", + "values": "Sheet1!$B$4:$D$4" + }], + "title": + { + "name": "Fruit 3D Clustered Column Chart" + } + }`); err != nil { fmt.Println(err) return } @@ -156,11 +180,18 @@ func main() { fmt.Println(err) } // Insert a picture to worksheet with scaling. - if err := f.AddPicture("Sheet1", "D2", "image.jpg", `{"x_scale": 0.5, "y_scale": 0.5}`); err != nil { + if err := f.AddPicture("Sheet1", "D2", "image.jpg", + `{"x_scale": 0.5, "y_scale": 0.5}`); err != nil { fmt.Println(err) } // Insert a picture offset in the cell with printing support. - if err := f.AddPicture("Sheet1", "H2", "image.gif", `{"x_offset": 15, "y_offset": 10, "print_obj": true, "lock_aspect_ratio": false, "locked": false}`); err != nil { + if err := f.AddPicture("Sheet1", "H2", "image.gif", `{ + "x_offset": 15, + "y_offset": 10, + "print_obj": true, + "lock_aspect_ratio": false, + "locked": false + }`); err != nil { fmt.Println(err) } // Save the spreadsheet with the origin path. |