read spreadsheet without knowing the number of rows in the column #1341
Replies: 3 comments 2 replies
-
Iterator row with row's iterator and get cells of each row, here is an example: package main
import (
"fmt"
"github.com/xuri/excelize/v2"
)
func main() {
f, err := excelize.OpenFile("Book1.xlsx")
if err != nil {
fmt.Println(err)
return
}
defer func() {
// Close the spreadsheet.
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
rows, err := f.Rows("Sheet1")
if err != nil {
fmt.Println(err)
return
}
rowNum := 0
for rows.Next() {
rowNum++
row, err := rows.Columns()
if err != nil {
fmt.Println(err)
}
fmt.Printf("row %d has %d columns\n", rowNum, len(row))
}
if err = rows.Close(); err != nil {
fmt.Println(err)
}
} |
Beta Was this translation helpful? Give feedback.
-
I think I expressed myself badly. |
Beta Was this translation helpful? Give feedback.
-
I think I'm still explaining it wrong hahaha. |
Beta Was this translation helpful? Give feedback.
-
hello friends, is it possible to read a worksheet and show the data of each column, without knowing the number of rows that will have in that worksheet? if yes, do you have an example?
Beta Was this translation helpful? Give feedback.
All reactions