玩一下golang操作excel

     最近要用golang操作excel,来玩下(https://github.com/360EntSecGroup-Skylar/excelize):

package main

import (
	"fmt"
	"github.com/360EntSecGroup-Skylar/excelize"
)

func main() {
	f, err := excelize.OpenFile("/xxxxxx/test.xlsx")
	if err != nil {
		fmt.Println(err)
		return
	}
	// Get value from cell by given worksheet name and axis.
	cell, err := f.GetCellValue("工作表1", "B2")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(cell)

	// Get all the rows in the Sheet1.
	rows, err := f.GetRows("工作表1")
	for i, row := range rows {
		for j, colCell := range row {
			fmt.Println(colCell, "---", i, j)
		}
		fmt.Println("")
	}
}

        结果:

go xxx
hello --- 0 0
helloxxx --- 0 1
helloyyy --- 0 2
end a --- 0 3

good --- 1 0
go xxx --- 1 1
go zzz --- 1 2
 --- 1 3

    

     excel中的内容为:

玩一下golang操作excel_第1张图片

       不多说。

 

你可能感兴趣的:(S1:,Go,s2:,软件进阶)