In Go, always check for errors. For example,

    mysheet := xlsx.GetSheetName(1)

https://godoc.org/github.com/360EntSecGroup-Skylar/excelize#File.GetSheetName

func (*File) GetSheetName

func (f *File) GetSheetName(index int) string

GetSheetName provides function to get sheet name of XLSX by given worksheet 
index. 
If given sheet index is invalid, will return an empty string.

Peter

On Friday, August 25, 2017 at 6:10:40 PM UTC-4, G Shields wrote:
>
> Under 1.8.3 the program run:
> package main
>
> import (
>     "fmt"
>     "os"
>     "strconv"
>
>     "github.com/Luxurioust/excelize"
> )
>
> func checkErr(err error) {
>     if err != nil {
>         fmt.Println(err)
>         os.Exit(1)
>     }
>
> }
> func main() {
>
>     xlsx, err := excelize.OpenFile("test.xlsx")
>     checkErr(err)
>     mysheet := xlsx.GetSheetName(1)
>     index := xlsx.GetSheetIndex(mysheet)
>     rows := xlsx.GetRows("Sheet" + strconv.Itoa(index))
>     for _, row := range rows {
>         for _, colCell := range row {
>             fmt.Print(colCell, "\t")
>         }
>         fmt.Println()
>     }
> }
>
> With results of:
> na    Apple    Orange    Pear    
> Small    2    3    3    
> Normal    5    2    4    
> Large    6    7    8
> Success: process exited with code 0.
>
> Under 1.9 I get no data and no errors:
> Success: process exited with code 0.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to