xls: github.com/extrame/xls Index | Examples | Files

package xls

import "github.com/extrame/xls"

xls package use to parse the 97 -2004 microsoft xls file(".xls" suffix, NOT ".xlsx" suffix )

there are some example in godoc, please follow them.

Index

Examples

Package Files

bof.go cell_range.go col.go date.go doc.go font.go format.go row.go sst.go workbook.go worksheet.go xf.go xls.go

Constants

const MJD_0 float64 = 2400000.5
const MJD_JD2000 float64 = 51544.5

Variables

var ErrIsInt = fmt.Errorf("is int")

type BlankCol Uses

type BlankCol struct {
    Col
    Xf  uint16
}

func (*BlankCol) String Uses

func (c *BlankCol) String(wb *WorkBook) []string

type CellRange Uses

type CellRange struct {
    FirstRowB uint16
    LastRowB  uint16
    FristColB uint16
    LastColB  uint16
}

range type of multi cells in multi rows

func (*CellRange) FirstCol Uses

func (c *CellRange) FirstCol() uint16

func (*CellRange) FirstRow Uses

func (c *CellRange) FirstRow() uint16

func (*CellRange) LastCol Uses

func (c *CellRange) LastCol() uint16

func (*CellRange) LastRow Uses

func (c *CellRange) LastRow() uint16

type Col Uses

type Col struct {
    RowB      uint16
    FirstColB uint16
}

func (*Col) FirstCol Uses

func (c *Col) FirstCol() uint16

func (*Col) LastCol Uses

func (c *Col) LastCol() uint16

func (*Col) Row Uses

func (c *Col) Row() uint16

func (*Col) String Uses

func (c *Col) String(wb *WorkBook) []string

type Coler Uses

type Coler interface {
    Row() uint16
}

type Font Uses

type Font struct {
    Info *FontInfo
    Name string
}

type FontInfo Uses

type FontInfo struct {
    Height     uint16
    Flag       uint16
    Color      uint16
    Bold       uint16
    Escapement uint16
    Underline  byte
    Family     byte
    Charset    byte
    Notused    byte
    NameB      byte
}

type Format Uses

type Format struct {
    Head struct {
        Index uint16
        Size  uint16
    }
    // contains filtered or unexported fields
}

type FormulaCol Uses

type FormulaCol struct {
    Header struct {
        Col
        IndexXf uint16
        Result  [8]byte
        Flags   uint16
        // contains filtered or unexported fields
    }
    Bts []byte
}

func (*FormulaCol) String Uses

func (c *FormulaCol) String(wb *WorkBook) []string
type HyperLink struct {
    CellRange
    Description      string
    TextMark         string
    TargetFrame      string
    Url              string
    ShortedFilePath  string
    ExtendedFilePath string
    IsUrl            bool
}

hyperlink type's content

func (*HyperLink) String Uses

func (h *HyperLink) String(wb *WorkBook) []string

get the hyperlink string, use the public variable Url to get the original Url

type LabelsstCol Uses

type LabelsstCol struct {
    Col
    Xf  uint16
    Sst uint32
}

func (*LabelsstCol) String Uses

func (c *LabelsstCol) String(wb *WorkBook) []string

type MulBlankCol Uses

type MulBlankCol struct {
    Col
    Xfs      []uint16
    LastColB uint16
}

func (*MulBlankCol) LastCol Uses

func (c *MulBlankCol) LastCol() uint16

func (*MulBlankCol) String Uses

func (c *MulBlankCol) String(wb *WorkBook) []string

type MulrkCol Uses

type MulrkCol struct {
    Col
    Xfrks    []XfRk
    LastColB uint16
}

func (*MulrkCol) LastCol Uses

func (c *MulrkCol) LastCol() uint16

func (*MulrkCol) String Uses

func (c *MulrkCol) String(wb *WorkBook) []string

type NumberCol Uses

type NumberCol struct {
    Col
    Index uint16
    Float float64
}

func (*NumberCol) String Uses

func (c *NumberCol) String(wb *WorkBook) []string

type RK Uses

type RK uint32

func (RK) Float Uses

func (rk RK) Float() (float64, error)

func (RK) String Uses

func (rk RK) String() string

type Ranger Uses

type Ranger interface {
    FirstRow() uint16
    LastRow() uint16
}

range type of multi rows

type RkCol Uses

type RkCol struct {
    Col
    Xfrk XfRk
}

func (*RkCol) String Uses

func (c *RkCol) String(wb *WorkBook) []string

type Row Uses

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

Row the data of one row

func (*Row) Col Uses

func (r *Row) Col(i int) string

Col Get the Nth Col from the Row, if has not, return nil. Suggest use Has function to test it.

func (*Row) FirstCol Uses

func (r *Row) FirstCol() int

FirstCol Get the number of First Col of the Row.

func (*Row) LastCol Uses

func (r *Row) LastCol() int

LastCol Get the number of Last Col of the Row.

type SstInfo Uses

type SstInfo struct {
    Total uint32
    Count uint32
}

type WorkBook Uses

type WorkBook struct {
    Is5ver   bool
    Type     uint16
    Codepage uint16
    Xfs      []st_xf_data
    Fonts    []Font
    Formats  map[uint16]*Format

    Author string
    // contains filtered or unexported fields
}

xls workbook type

func Open Uses

func Open(file string, charset string) (*WorkBook, error)

Open one xls file

Code:

if xlFile, err := Open("Table.xls", "utf-8"); err == nil {
    fmt.Println(xlFile.Author)
}

func OpenReader Uses

func OpenReader(reader io.ReadSeeker, charset string) (wb *WorkBook, err error)

Open xls file from reader

func OpenWithCloser Uses

func OpenWithCloser(file string, charset string) (*WorkBook, io.Closer, error)

Open one xls file and return the closer

func (*WorkBook) GetSheet Uses

func (w *WorkBook) GetSheet(num int) *WorkSheet

Get one sheet by its number

Output: read the content of first two cols in each row

Code:

if xlFile, err := Open("Table.xls", "utf-8"); err == nil {
    if sheet1 := xlFile.GetSheet(0); sheet1 != nil {
        fmt.Print("Total Lines ", sheet1.MaxRow, sheet1.Name)
        col1 := sheet1.Row(0).Col(0)
        col2 := sheet1.Row(0).Col(0)
        for i := 0; i <= (int(sheet1.MaxRow)); i++ {
            row1 := sheet1.Row(i)
            col1 = row1.Col(0)
            col2 = row1.Col(1)
            fmt.Print("\n", col1, ",", col2)
        }
    }
}

func (*WorkBook) NumSheets Uses

func (w *WorkBook) NumSheets() int

Get the number of all sheets, look into example

func (*WorkBook) Parse Uses

func (w *WorkBook) Parse(buf io.ReadSeeker)

func (*WorkBook) ReadAllCells Uses

func (w *WorkBook) ReadAllCells(max int) (res [][]string)

helper function to read all cells from file Notice: the max value is the limit of the max capacity of lines. Warning: the helper function will need big memeory if file is large.

type WorkSheet Uses

type WorkSheet struct {
    Name string

    //NOTICE: this is the max row number of the sheet, so it should be count -1
    MaxRow uint16
    // contains filtered or unexported fields
}

WorkSheet in one WorkBook

func (*WorkSheet) Row Uses

func (w *WorkSheet) Row(i int) *Row

type Xf5 Uses

type Xf5 struct {
    Font      uint16
    Format    uint16
    Type      uint16
    Align     uint16
    Color     uint16
    Fill      uint16
    Border    uint16
    Linestyle uint16
}

type Xf8 Uses

type Xf8 struct {
    Font        uint16
    Format      uint16
    Type        uint16
    Align       byte
    Rotation    byte
    Ident       byte
    Usedattr    byte
    Linestyle   uint32
    Linecolor   uint32
    Groundcolor uint16
}

type XfRk Uses

type XfRk struct {
    Index uint16
    Rk    RK
}

func (*XfRk) String Uses

func (xf *XfRk) String(wb *WorkBook) string

Package xls imports 13 packages (graph) and is imported by 8 packages. Updated 2019-11-12. Refresh now. Tools for package owners.