-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get CountRows from sheet #1402
Comments
There are two kinds of methods to get total rows in the worksheet, for example, get the length of the trows by the f, err := excelize.OpenFile("Book1.xlsx")
if err != nil {
return
}
defer func() {
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
rows, err := f.GetRows("Sheet1")
if err != nil {
return
}
fmt.Println("total rows:", len(rows)) For better performance, please use the row iterator: f, err := excelize.OpenFile("Book1.xlsx")
if err != nil {
return
}
defer func() {
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
var totalRows int
rows, err := f.Rows("Sheet1")
if err != nil {
return
}
for rows.Next() {
totalRows++
}
if err = rows.Close(); err != nil {
fmt.Println(err)
}
fmt.Println("total rows:", totalRows) |
Thanks for the answer, the proposed options work very slowly. I did faster and ran tests. Please take a look at my solution. |
Thanks for your pull request, I've review it later. |
add close file and benchmark
This is optional and is not required. |
What a pity :( |
Description
I need to know the number of lines, and I'm ready to offer a solution. Is this idea okay?
The text was updated successfully, but these errors were encountered: