Giter Club home page Giter Club logo

Comments (1)

xuri avatar xuri commented on May 16, 2024

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.

from excelize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.