summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md43
1 files changed, 37 insertions, 6 deletions
diff --git a/README.md b/README.md
index 4dbf532..7c67092 100644
--- a/README.md
+++ b/README.md
@@ -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.