D
D
Dima Zherebko2015-12-12 15:22:06
go
Dima Zherebko, 2015-12-12 15:22:06

What type of data should the function take?

excelFileName := "C:\\gowork\\src\\xl4\\test1.xlsx"
  excelFileName2 := "C:\\gowork\\src\\xl4\\test2.xlsx"
  //open
  xlFile1, error1 := xlsx.OpenFile(excelFileName)
  xlFile2, error2 := xlsx.OpenFile(excelFileName2)
  //error
  if error1 != nil && error2 != nil {
    fmt.Println("file open errr")
  }
  
  
  sh1 := xlFile1.Sheets[0]
  sh2 := xlFile2.Sheets[0]

what type of data should the function take if i need to pass it sh1 sh2 ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Shevelev, 2015-12-12
@G_tost

Learn to read documentation. https://godoc.org/github.com/tealeg/xlsx#File
1. find the function that started it all,
2. see that it returns the type File, find this type,

type File struct {
    Date1904 bool

    Sheets []*Sheet
    Sheet  map[string]*Sheet
    // contains filtered or unexported fields
}

3. see that in Sheets there is a *Sheet slice
4. find the Sheet type
type Sheet struct {
    Name        string
    File        *File
    Rows        []*Row
    Cols        []*Col
    MaxRow      int
    MaxCol      int
    Hidden      bool
    Selected    bool
    SheetViews  []SheetView
    SheetFormat SheetFormat
}

5. study... what where where and why... https://godoc.org/ and the source code to help you. And don’t ask such questions anymore, otherwise you don’t want to help the lazy :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question