From 50863294f9d6f2ecc399d06f1b3c2312c4bdce10 Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Mon, 5 Sep 2016 16:37:15 +0800 Subject: Fix issue #2 change project to object-oriented style and update readme file. --- README.md | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 357c92d..1cfe4e5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ## Introduction -Excelize is a library written in pure Golang and providing a set of functions that allow you to write to and read from XLSX files. Support reads and writes XLSX file generated by Office Excel 2007 and later. The full API docs can be seen using go's built-in documentation tool, or online at [godoc.org](https://godoc.org/github.com/Luxurioust/excelize). +Excelize is a library written in pure Golang and providing a set of functions that allow you to write to and read from XLSX files. Support reads and writes XLSX file generated by Office Excel 2007 and later. Support save file without losing original charts of XLSX. The full API docs can be seen using go's built-in documentation tool, or online at [godoc.org](https://godoc.org/github.com/Luxurioust/excelize). ## Basic Usage @@ -35,11 +35,11 @@ import ( func main() { xlsx := excelize.CreateFile() - xlsx = excelize.NewSheet(xlsx, 2, "Sheet2") - xlsx = excelize.NewSheet(xlsx, 3, "Sheet3") - xlsx = excelize.SetCellInt(xlsx, "Sheet2", "A23", 10) - xlsx = excelize.SetCellStr(xlsx, "Sheet3", "B20", "Hello") - err := excelize.Save(xlsx, "/home/Workbook.xlsx") + xlsx.NewSheet(2, "Sheet2") + xlsx.NewSheet(3, "Sheet3") + xlsx.SetCellInt("Sheet2", "A23", 10) + xlsx.SetCellStr("Sheet3", "B20", "Hello") + err := xlsx.WriteTo("/home/Workbook.xlsx") if err != nil { fmt.Println(err) } @@ -59,20 +59,17 @@ import ( ) func main() { - xlsx, err := excelize.OpenFile("/home/Workbook.xlsx") + xlsx := excelize.OpenFile("/home/Workbook.xlsx") + xlsx.SetCellInt("Sheet2", "B2", 100) + xlsx.SetCellStr("Sheet2", "C11", "Hello") + xlsx.NewSheet(3, "TestSheet") + xlsx.SetCellInt("Sheet3", "A23", 10) + xlsx.SetCellStr("Sheet3", "b230", "World") + xlsx.SetActiveSheet(2) + err := xlsx.Save() if err != nil { fmt.Println(err) } - xlsx = excelize.SetCellInt(xlsx, "Sheet2", "B2", 100) - xlsx = excelize.SetCellStr(xlsx, "Sheet2", "C11", "Hello") - xlsx = excelize.NewSheet(xlsx, 3, "TestSheet") - xlsx = excelize.SetCellInt(xlsx, "Sheet3", "A23", 10) - xlsx = excelize.SetCellStr(xlsx, "Sheet3", "b230", "World") - xlsx = excelize.SetActiveSheet(xlsx, 2) - err = excelize.Save(xlsx, "/home/Workbook.xlsx") - if err != nil { - fmt.Println(err) - } } ``` @@ -87,11 +84,8 @@ import ( ) func main() { - xlsx, err := excelize.OpenFile("/home/Workbook.xlsx") - if err != nil { - fmt.Println(err) - } - cell := excelize.GetCellValue(file, "Sheet2", "D11") + xlsx := excelize.OpenFile("/home/Workbook.xlsx") + cell := xlsx.GetCellValue("Sheet2", "D11") fmt.Println(cell) } ``` -- cgit v1.2.1