excel

package
v0.0.0-...-fc992ad Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotMSExcel = fmt.Errorf("not Microsoft Excel")
View Source
var ErrSheetNotAvailable = fmt.Errorf("sheet not available")

Functions

This section is empty.

Types

type Cell

type Cell struct {
	XMLName xml.Name `xml:"c"`
	Value   string   `xml:"v"`
}

type OpenXML

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

OpenXML defines an Excel Open XML file.

func New

func New(filename string) (*OpenXML, error)

New takes filename as the location of an Excel Open XML file and tries to open it. This will fail for any other Open XML files and return error ErrNotMSExcel. The caller must call OpenXML.Close() when reader is no longer needed.

func NewWithReader

func NewWithReader(r io.Reader, size int64) (*OpenXML, error)

NewWithReader opens the Excel Open XML file for reading using an io.Reader. The size argument is the size of the ZIP-file.

func (*OpenXML) Close

func (ox *OpenXML) Close() error

Close the reader. This must be called when reader is no longer needed. When ox was created using an io.Reader, Close does not do anything.

func (*OpenXML) MustClose

func (ox *OpenXML) MustClose()

MustClose the reader but panics on error instead. This is mainly useful for tests. See Close.

func (*OpenXML) Sheets

func (ox *OpenXML) Sheets() ([]*Sheet, error)

func (*OpenXML) Worksheet

func (ox *OpenXML) Worksheet(name string) (*Worksheet, error)

type Relationship

type Relationship struct {
	XMLName xml.Name `xml:"Relationship"`
	ID      string   `xml:"Id,attr"`
	Type    string   `xml:"Type,attr"`
	Target  string   `xml:"Target,attr"`
}

type Relationships

type Relationships struct {
	XMLName       xml.Name        `xml:"Relationships"`
	Relationships []*Relationship `xml:"Relationship"`
}

func (*Relationships) GetID

func (rels *Relationships) GetID(id string) *Relationship

type Row

type Row struct {
	XMLName xml.Name `xml:"row"`
	Cells   []Cell   `xml:"c"`
}

type Sheet

type Sheet struct {
	XMLName    xml.Name `xml:"sheet"`
	Name       string   `xml:"name,attr"`
	SheetID    int      `xml:"sheetId,attr"`
	RelationID string   `xml:"id,attr"`

	Target string
}

type SheetData

type SheetData struct {
	XMLName xml.Name `xml:"sheetData"`
	Rows    []Row    `xml:"row"`
}

type Workbook

type Workbook struct {
	XMLName xml.Name `xml:"workbook"`
	Sheets  []*Sheet `xml:"sheets>sheet"`
}

type Worksheet

type Worksheet struct {
	XMLName   xml.Name  `xml:"worksheet"`
	SheetData SheetData `xml:"sheetData"`
}

Jump to

Keyboard shortcuts

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