summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2017-09-13 22:00:33 +0800
committerRi Xu <xuri.me@gmail.com>2017-09-13 22:00:33 +0800
commitf05f799f8d33e24b3bbf6c030c9f22d2829e0748 (patch)
treedff6b11b838c5ee26ea8c0fcf1af26bba8355702 /README.md
parent3e7192b6abaa9c8db29a2e34867879ebc9fedca7 (diff)
- API changed, use worksheet name instead of "sheet" + index, related issue #25, #43, #47, #51, #89, #101, #116 and #120.
- go test updated
Diffstat (limited to 'README.md')
-rw-r--r--README.md18
1 files changed, 8 insertions, 10 deletions
diff --git a/README.md b/README.md
index 3d6383b..58c275f 100644
--- a/README.md
+++ b/README.md
@@ -38,12 +38,12 @@ import (
func main() {
xlsx := excelize.NewFile()
// Create a new sheet.
- xlsx.NewSheet(2, "Sheet2")
+ index := xlsx.NewSheet("Sheet2")
// Set value of a cell.
xlsx.SetCellValue("Sheet2", "A2", "Hello world.")
xlsx.SetCellValue("Sheet1", "B2", 100)
// Set active sheet of the workbook.
- xlsx.SetActiveSheet(2)
+ xlsx.SetActiveSheet(index)
// Save xlsx file by the given path.
err := xlsx.SaveAs("./Workbook.xlsx")
if err != nil {
@@ -63,7 +63,6 @@ package main
import (
"fmt"
"os"
- "strconv"
"github.com/xuri/excelize"
)
@@ -74,13 +73,11 @@ func main() {
fmt.Println(err)
os.Exit(1)
}
- // Get value from cell by given sheet index and axis.
+ // Get value from cell by given worksheet name and axis.
cell := xlsx.GetCellValue("Sheet1", "B2")
fmt.Println(cell)
- // Get sheet index.
- index := xlsx.GetSheetIndex("Sheet2")
- // Get all the rows in a sheet.
- rows := xlsx.GetRows("sheet" + strconv.Itoa(index))
+ // Get all the rows in the Sheet1.
+ rows := xlsx.GetRows("Sheet1")
for _, row := range rows {
for _, colCell := range row {
fmt.Print(colCell, "\t")
@@ -88,11 +85,12 @@ func main() {
fmt.Println()
}
}
+
```
### Add chart to XLSX 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 sheet at all.
+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.
![Excelize](./test/images/chart.png "Excelize")
@@ -152,7 +150,7 @@ func main() {
if err != nil {
fmt.Println(err)
}
- // Insert a picture to sheet with scaling.
+ // Insert a picture to worksheet with scaling.
err = xlsx.AddPicture("Sheet1", "D2", "./image2.jpg", `{"x_scale": 0.5, "y_scale": 0.5}`)
if err != nil {
fmt.Println(err)