goxlsx

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2018 License: MIT Imports: 8 Imported by: 1

README

goxlsx

Excel-XML reader for Go

Installation

go get github.com/speedata/goxlsx

Usage example

package main

import (
    "fmt"
    "log"

    "github.com/speedata/goxlsx"
)

func main() {
    excelfile := "Worksheet1.xlsx"
    spreadsheet, err := goxlsx.OpenFile(excelfile)
    if err != nil {
        log.Fatal(err)
    }
    ws1, err := spreadsheet.GetWorksheet(0)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(ws1.Name)
    fmt.Printf("Spreadsheet 0 (%s) starts at (%d,%d) and extends to (%d,%d)\n", ws1.Name, ws1.MinColumn, ws1.MinRow, ws1.MaxColumn, ws1.MaxRow)
    fmt.Println(ws1.Cell(ws1.MinColumn, ws1.MinRow))
    fmt.Println(ws1.Cell(3, 3))

}

Other:

Status: usable
Maturity level: 3/5 (used in production, but expect changes)
Supported/maintained: yes
Contribution welcome: yes (pull requests, issues)
Main page: https://github.com/speedata/goxlsx
License: MIT
Contact: gundlach@speedata.de

Documentation

Overview

Package goxlsx accesses Excel 2007 (.xslx) for reading.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Spreadsheet

type Spreadsheet struct {
	// contains filtered or unexported fields
}

Spreadsheet represents the whole .xlsx file.

func OpenFile

func OpenFile(path string) (*Spreadsheet, error)

OpenFile reads a file located at the given path and returns a spreadsheet object.

func (*Spreadsheet) GetWorksheet

func (s *Spreadsheet) GetWorksheet(number int) (*Worksheet, error)

GetWorksheet returns the worksheet with the given number, starting at 0.

func (*Spreadsheet) NumWorksheets

func (s *Spreadsheet) NumWorksheets() int

NumWorksheets returns the number of worksheets in a file.

type Worksheet

type Worksheet struct {
	Name      string
	MaxRow    int
	MaxColumn int
	MinRow    int
	MinColumn int
	// contains filtered or unexported fields
}

Worksheet represents a single worksheet in an excel file. A worksheet is a rectangular area of cells, each cell can contain a value.

func (*Worksheet) Cell

func (ws *Worksheet) Cell(column, row int) string

Cell returns the contents of cell at column, row, where 1,1 is the top left corner. The return value is always a string. The user is in charge to convert this value to a number, if necessary. Formulae are not returned.

func (*Worksheet) Cellf

func (ws *Worksheet) Cellf(column, row int) (float64, error)

Cell returns the contents of cell at column, row, where 1,1 is the top left corner. The return value is always a float64 and an error code != nil if the cell contents can't be decoded as a float.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL