Documentation
¶
Index ¶
- Constants
- Variables
- func ByteToUint16(b []byte) uint16
- func ByteToUint32(b []byte) uint32
- type BlankCol
- type CellRange
- type Col
- type Coler
- type ExtSheetInfo
- type Font
- type FontInfo
- type Format
- type FormulaCol
- type HyperLink
- type LabelsstCol
- type MulBlankCol
- type MulrkCol
- type NumberCol
- type RK
- type Ranger
- type RkCol
- type Row
- type SstInfo
- type WorkBook
- type WorkSheet
- type XF
- type Xf5
- type Xf8
- type XfRk
Examples ¶
Constants ¶
const ( TYPE_STRING2 = iota + 1 TYPE_STRING // 2 TYPE_FORMULA // 3 TYPE_NUMERIC // 4 TYPE_BOOL // 5 TYPE_NULL // 6 TYPE_INLINE // 7 TYPE_ERROR // 8 TYPE_DATETIME // 9 TYPE_PERCENTAGE // 10 TYPE_CURRENCY // 11 )
Data types
Variables ¶
var ErrIsInt = errors.New("is int")
Functions ¶
Types ¶
type CellRange ¶
CellRange is range type of multi cells in multi rows
type ExtSheetInfo ¶
ExtSheetInfo external sheet references provided for named cells
type FontInfo ¶
type FontInfo struct {
Height uint16
Flag uint16
Color uint16
Bold uint16
Escapement uint16
Underline byte
Family byte
Charset byte
Notused byte
NameB byte
}
FontInfo represents the font info
type Format ¶
type Format struct {
Head struct {
Index uint16
Size uint16
}
Raw []string
// contains filtered or unexported fields
}
Format value interface
type FormulaCol ¶
type FormulaCol struct {
Code uint16
Btl uint16
Btc uint16
Bts []byte
Header *formulaColHeader
// contains filtered or unexported fields
}
FormulaCol represents formula cell
func (*FormulaCol) Debug ¶
func (c *FormulaCol) Debug(wb *WorkBook)
func (*FormulaCol) FirstCol ¶
func (c *FormulaCol) FirstCol() uint16
func (*FormulaCol) IsRef ¶
func (c *FormulaCol) IsRef() bool
IsRef return true if cell is reference to other cell
func (*FormulaCol) LastCol ¶
func (c *FormulaCol) LastCol() uint16
func (*FormulaCol) Row ¶
func (c *FormulaCol) Row() uint16
func (*FormulaCol) String ¶
func (c *FormulaCol) String(wb *WorkBook) []string
type HyperLink ¶
type HyperLink struct {
CellRange
Description string
TextMark string
TargetFrame string
Url string
ShortedFilePath string
ExtendedFilePath string
IsUrl bool
}
HyperLink represents a hyperlink's content
type LabelsstCol ¶
func (*LabelsstCol) Debug ¶
func (c *LabelsstCol) Debug(wb *WorkBook)
func (*LabelsstCol) String ¶
func (c *LabelsstCol) String(wb *WorkBook) []string
type MulBlankCol ¶
func (*MulBlankCol) Debug ¶
func (c *MulBlankCol) Debug(wb *WorkBook)
func (*MulBlankCol) LastCol ¶
func (c *MulBlankCol) LastCol() uint16
func (*MulBlankCol) String ¶
func (c *MulBlankCol) String(wb *WorkBook) []string
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row the data of one row
type WorkBook ¶
type WorkBook struct {
Is5ver bool
Type uint16
Codepage uint16
Xfs []XF
Fonts []Font
Formats map[uint16]*Format
Author string
// contains filtered or unexported fields
}
WorkBook represents xls workbook type
func Open ¶
Open open one xls file with some charset
Example ¶
if xlFile, err := Open("./testdata/Table.xls", "utf-8"); err == nil {
fmt.Println(xlFile.Author)
}
func OpenReader ¶
func OpenReader(reader io.ReadSeeker, charset string) (wb *WorkBook, err error)
OpenReader open xls file from reader
func OpenWithBuffer ¶
OpenWithBuffer open one xls file with memory buffer
func OpenWithCloser ¶
OpenWithCloser open one xls file and return the closer
func (*WorkBook) GetSheet ¶
GetSheet gets one sheet by its number
Example ¶
Output: read the content of first two cols in each row
if xlFile, err := Open("./testdata/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 ¶
NumSheets get the number of all sheets, look into example
Example ¶
if xlFile, err := Open("./testdata/Table.xls", "utf-8"); err == nil {
for i := 0; i < xlFile.NumSheets(); i++ {
sheet := xlFile.GetSheet(i)
fmt.Println(sheet.Name)
}
}
func (*WorkBook) ReadAllCells ¶
ReadAllCells 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 memory if file is large.
type WorkSheet ¶
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