Categorygithub.com/beta/spreadsheet
modulepackage
1.0.1
Repository: https://github.com/beta/spreadsheet.git
Documentation: pkg.go.dev

# README

Spreadsheet

Spreadsheet is a Go package providing a simple interface for reading spreadsheet files, including XLSX and CSV.

Installation

Please use gopkg.in for stable releases.

go get -u gopkg.in/beta/spreadsheet.v1

Getting started

For full documentation please refer to https://godoc.org/github.com/beta/spreadsheet.

package main

import (
	"fmt"

	"gopkg.in/beta/spreadsheet.v1"
)

func main() {
	// Open sheet.
	ss, err := spreadsheet.Open("test.xlsx")
	if err != nil {
		panic(err)
	}

	s1 := ss.Sheets[0]
	fmt.Printf("Sheet name: %s\n", s1.Name)
	// Traverse sheet.
	for _, row := range s1.Rows {
		for _, cell := range row.Cells {
			switch cell.Type() {
			case spreadsheet.String:
				fmt.Printf("Value: %s\n", cell.String())
			case spreadsheet.Numeric:
				f, _ := cell.Float()
				fmt.Printf("Value: %f\n", f)
				i, _ := cell.Int()
				fmt.Printf("Value: %d\n", i)
				i64, _ := cell.Int64()
				fmt.Printf("Value: %d\n", i64)
			case spreadsheet.Bool:
				b, _ := cell.Bool()
				fmt.Printf("Value: %t\n", b)
			}
		}
	}

	s2 := ss.SheetsByName["Sheet 2"] // Pick sheet by name.
	cell := s2.Cell(2, 3)            // Pick cell by coordinate.
	if cell.Is(spreadsheet.String) { // Check cell type.
		fmt.Printf("Value: %s\n", cell.String())
	}
}

License

MIT

# Packages

No description provided by the author

# Functions

Open opens a spreadsheet file.

# Constants

CellDataType constants.
CellDataType constants.
CellDataType constants.

# Structs

Cell holds a single piece of data in a spreadsheet.
Row is a single row of data in a spreadsheet, containing multiple cells.
Sheet is a single page in a spreadsheet.
Spreadsheet is a high-level interface for spreadsheet files including XLSX, XLS and CSV.

# Type aliases

CellDataType represents the primitive data type in spreadsheet cells.