Closed answer91 closed 3 months ago
Thanks for your issue. As the documentation says, the Excelize library provides a set of utility functions that allow you to convert between cell names and coordinates, you can also use these functions when iterating rows or column cells. For example, convert column/row index to cell name when iterating rows:
package main
import (
"fmt"
"github.com/xuri/excelize/v2"
)
func main() {
f := excelize.NewFile()
defer func() {
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
if err := f.SetSheetRow("Sheet1", "A1", &[]interface{}{1, 2}); err != nil {
fmt.Println(err)
return
}
if err := f.SetSheetRow("Sheet1", "A2", &[]interface{}{3, 4}); err != nil {
fmt.Println(err)
return
}
rows, err := f.GetRows("Sheet1")
if err != nil {
fmt.Println(err)
return
}
for rowIdx, row := range rows {
for colIdx, cell := range row {
// Convert column/row index to cell name
cellName, err := excelize.CoordinatesToCellName(colIdx+1, rowIdx+1)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("value of cell %s is %s\r\n", cellName, cell)
}
}
}
I've closed this issue. If you have any questions, please let me know, and you can reopen this anytime.
Description
Steps to reproduce the issue: 1. 2. 3.
Describe the results you received:
Describe the results you expected:
Output of
go version
:Excelize version or commit ID:
Environment details (OS, Microsoft Excel™ version, physical, etc.):