Documentation
¶
Index ¶
- Constants
- func CellNameToCoordinates(cellName string) (int, int)
- func ColumnName(columnNumber int) (columnName string)
- func ColumnNumber(columnName string) (columnNumber int)
- func CoordinatesToCellName(col, row int) string
- func DeepCopy(dst, src interface{}) error
- func TimeToExcelTime(t time.Time) float64
- type Cell
- func (c *Cell) Col() int
- func (c *Cell) GetIntValue() int
- func (c *Cell) GetStringValue() string
- func (c *Cell) Row() int
- func (c *Cell) SetBoolValue(value bool)
- func (c *Cell) SetDefaultValue(value string)
- func (c *Cell) SetDurationValue(value time.Duration)
- func (c *Cell) SetFloatValue(value float64)
- func (c *Cell) SetFloatValuePrec(value float64, prec int, bitSize int)
- func (c *Cell) SetIntValue(value int)
- func (c *Cell) SetStringValue(value string)
- func (c *Cell) SetTimeValue(value time.Time)
- func (c *Cell) SetValue(value interface{})
- type File
- type Sheet
- type StyleSheet
- type Vector
Constants ¶
const ( VariantTypeVariant = "variant" VariantTypeVTLPSTR = "lpstr" )
VariantTypes
Variables ¶
This section is empty.
Functions ¶
func CellNameToCoordinates ¶
CellNameToCoordinates convert cell name to [col, row] coordinates
Example:
xlsx.CellNameToCoordinates("A1") // returns 1, 1 xlsx.CellNameToCoordinates("B5") // returns 2, 5
func ColumnName ¶
ColumnName convert the column number to column name
Example:
xlsx.ColumnName(51) // returns "AY"
func ColumnNumber ¶
ColumnNumber convert the column name to column number
Example:
xlsx.ColumnNumber("AY") // returns 51
func CoordinatesToCellName ¶
CoordinatesToCellName convert [col, row] coordinates to cell name
Example:
xlsx.CoordinatesToCellName(1, 1) // returns "A1"
func DeepCopy ¶
func DeepCopy(dst, src interface{}) error
DeepCopy deepcopy object. can without same type
Example:
type A struct { Name string Value int } type B struct { Name string Value int } a := &A { Name: "Jason", 100} var b B xlsx.DeepCopy(&b, a) fmt.Printf("%+v\n", b)
func TimeToExcelTime ¶
TimeToExcelTime convert time.Time to excel time format
Types ¶
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
Cell cell operator
func (*Cell) GetIntValue ¶
GetIntValue get cell value with int type
func (*Cell) GetStringValue ¶
GetStringValue get cell value with string type
func (*Cell) SetBoolValue ¶
SetBoolValue set cell value for bool type
func (*Cell) SetDefaultValue ¶
SetDefaultValue set cell value without any type
func (*Cell) SetDurationValue ¶
SetDurationValue set cell value for time.Duration type
func (*Cell) SetFloatValue ¶
SetFloatValue set cell for float64 type
func (*Cell) SetFloatValuePrec ¶
SetFloatValuePrec set cell for float64 type with pres
func (*Cell) SetStringValue ¶
SetStringValue set cell value for string type
func (*Cell) SetTimeValue ¶
SetTimeValue set cell value for time.Time type
func (*Cell) SetValue ¶
func (c *Cell) SetValue(value interface{})
SetValue provides to set the value of a cell Allow Types:
int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float32 float64 string []byte time.Duration time.Time bool nil
Example:
cell.SetValue(100) cell.SetValue("Hello") cell.SetValue(3.14)
type File ¶
type File struct {
// contains filtered or unexported fields
}
File define for operation xlsx file
func (*File) NewSheet ¶
NewSheet create a new *Sheet with sheet name Example:
sheet := file.NewSheet("Sheet2")
type Sheet ¶
type Sheet struct {
// contains filtered or unexported fields
}
Sheet sheet operator
func (*Sheet) GetCellInt ¶
GetCellInt get cell value of string
Example:
sheet.GetCellInt(3, 1) // C1 => 1000
func (*Sheet) GetCellString ¶
GetCellString get cell value of string
Example:
sheet.GetCellString(1, 1) // A1 => "val"
func (*Sheet) SetCellValue ¶
SetCellValue set cell value
Example:
sheet.SetCellValue(1, 1, "val") // A1 => "val" sheet.SetCellValue(2, 3, 98.01) // B3 => 98.01 sheet.SetCellValue(3, 1, 1000) // C1 => 1000 sheet.SetCellValue(4, 4, time.Now()) // D4 => "2021-03-11 05:19:16.483"
type StyleSheet ¶
type StyleSheet struct {
// contains filtered or unexported fields
}
StyleSheet style operator
type Vector ¶
type Vector struct {
// contains filtered or unexported fields
}
Vector for operation xml vt:vector node
func (*Vector) AppendString ¶
AppendString append lpstr to array
Example:
InputXML: <vt:vector size="2" baseType="lpstr"> <vt:lpstr>Sheet1</vt:lpstr> </vt:vector> vector.AppendString("Sheet2") OutputXML: <vt:vector size="2" baseType="lpstr"> <vt:lpstr>Sheet1</vt:lpstr> <vt:lpstr>Sheet2</vt:lpstr> </vt:vector>
func (*Vector) GetIntPairs ¶
GetIntPairs get variant type pairs
Example:
InputXML: <vt:vector size="2" baseType="variant"> <vt:variant> <vt:lpstr>Worksheets</vt:lpstr> </vt:variant> <vt:variant> <vt:i4>1</vt:i4> </vt:variant> </vt:vector> vector.GetIntPairs() // => map[Worksheets 1]
func (*Vector) GetStringArray ¶
GetStringArray get lpstr array
Example:
InputXML: <vt:vector size="2" baseType="lpstr"> <vt:lpstr>Sheet1</vt:lpstr> <vt:lpstr>Sheet2</vt:lpstr> </vt:vector> vector.GetStringArray() // => [Sheet1 Sheet2]
func (*Vector) SetIntPairs ¶
SetIntPairs set pairs for variant type
Example:
variantPairs := map[string]int { "Worksheets": 1, } vector.SetIntPairs(variantPairs) OutputXML: <vt:vector size="2" baseType="variant"> <vt:variant> <vt:lpstr>Worksheets</vt:lpstr> </vt:variant> <vt:variant> <vt:i4>1</vt:i4> </vt:variant> </vt:vector>
func (*Vector) SetStringArray ¶
SetStringArray set lpstr array
Example:
vector.SetStringArray([]string{"Sheet1", "Sheet2"}) OutputXML: <vt:vector size="2" baseType="lpstr"> <vt:lpstr>Sheet1</vt:lpstr> <vt:lpstr>Sheet2</vt:lpstr> </vt:vector>