An open API service indexing awesome lists of open source software.

https://github.com/chonla/cellwalker

Excel Cell Name Traversal for Go
https://github.com/chonla/cellwalker

golang-library

Last synced: 3 months ago
JSON representation

Excel Cell Name Traversal for Go

Awesome Lists containing this project

README

          

# Cell Walker

[![codecov](https://codecov.io/github/chonla/cellwalker/graph/badge.svg?token=N2WFUOD9OB)](https://codecov.io/github/chonla/cellwalker) [![Go Report Card](https://goreportcard.com/badge/github.com/chonla/cellwalker)](https://goreportcard.com/report/github.com/chonla/cellwalker) [![Go Reference](https://pkg.go.dev/badge/github.com/chonla/cellwalker.svg)](https://pkg.go.dev/github.com/chonla/cellwalker)

Cell Walker is a go package for virtually traversing Excel cell by cell's name. The package does not actually traverse into a real Excel file.

## Example

```go
package main

import (
"fmt"

"github.com/chonla/cellwalker"
)

func main() {
// Walk from a cell to other cell
fmt.Println(cellwalker.At("B3").Right().Below().String()) // C4

// Jump from a cell to other cell
fmt.Println(cellwalker.At("C2").ColumnOffset(5).RowOffset(10).String()) // H12

// Too far jump from a cell to other cell will hit the limit of boundary
fmt.Println(cellwalker.At("ZZZ2").ColumnOffset(5).RowOffset(10).String()) // XFD12

// Range walking apply other boundary to walker
fmt.Println(cellwalker.Within("C2:H3").At("C3").Right().Below().String()) // D3

// Too far jump in a new boundary
fmt.Println(cellwalker.Within("C2:H3").At("ZZZ2").ColumnOffset(5).RowOffset(10).String()) // XFD12

// Range traversal
result1 := cellwalker.Within("B3:E5").At("C4") // Define range and initial cell position
fmt.Println(result1.String()) // C4
result2 := result1.Tour()
fmt.Println(result2.String()) // D4
result3 := result2.Tour()
fmt.Println(result3.String()) // E4
result4 := result3.Tour()
fmt.Println(result4.String()) // B5
result5 := result4.Tour()
fmt.Println(result5.String()) // C5
result6 := result5.Tour()
fmt.Println(result6.String()) // D5
result7 := result6.Tour()
fmt.Println(result7.String()) // E5
result8 := result7.Tour()
fmt.Println(result8 == nil) // true
}
```

## License

[MIT](LICENSE)