-
Notifications
You must be signed in to change notification settings - Fork 214
/
Copy pathcol.go
145 lines (118 loc) · 2.07 KB
/
col.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package xls
import (
"fmt"
"math"
)
type ContentHandler interface {
String(*WorkBook) []string
FirstCol() uint16
LastCol() uint16
}
type Col struct {
RowB uint16
FirstColB uint16
}
type Coler interface {
Row() uint16
}
func (c *Col) Row() uint16 {
return c.RowB
}
func (c *Col) FirstCol() uint16 {
return c.FirstColB
}
func (c *Col) LastCol() uint16 {
return c.FirstColB
}
func (c *Col) String(wb *WorkBook) []string {
return []string{"default"}
}
type XfRk struct {
Index uint16
Rk RK
}
type RK uint32
func (rk RK) String() string {
multiplied := rk & 1
isInt := rk & 2
val := rk >> 2
if isInt == 0 {
f := math.Float64frombits(uint64(val) << 34)
if multiplied != 0 {
f = f / 100
}
return fmt.Sprintf("%.1f", f)
} else {
return fmt.Sprint(val)
}
}
type MulrkCol struct {
Col
Xfrks []XfRk
LastColB uint16
}
func (c *MulrkCol) LastCol() uint16 {
return c.LastColB
}
func (c *MulrkCol) String(wb *WorkBook) []string {
var res = make([]string, len(c.Xfrks))
for i := 0; i < len(c.Xfrks); i++ {
xfrk := c.Xfrks[i]
res[i] = xfrk.Rk.String()
}
return res
}
type MulBlankCol struct {
Col
Xfs []uint16
LastColB uint16
}
func (c *MulBlankCol) LastCol() uint16 {
return c.LastColB
}
func (c *MulBlankCol) String(wb *WorkBook) []string {
return make([]string, len(c.Xfs))
}
type NumberCol struct {
Col
Index uint16
Float float64
}
func (c *NumberCol) String(wb *WorkBook) []string {
return []string{fmt.Sprintf("%f", c.Float)}
}
type FormulaCol struct {
Header struct {
Col
IndexXf uint16
Result [8]byte
Flags uint16
_ uint32
}
Bts []byte
}
func (c *FormulaCol) String(wb *WorkBook) []string {
return []string{"FormulaCol"}
}
type RkCol struct {
Col
Xfrk XfRk
}
func (c *RkCol) String(wb *WorkBook) []string {
return []string{c.Xfrk.Rk.String()}
}
type LabelsstCol struct {
Col
Xf uint16
Sst uint32
}
func (c *LabelsstCol) String(wb *WorkBook) []string {
return []string{wb.sst[int(c.Sst)]}
}
type BlankCol struct {
Col
Xf uint16
}
func (c *BlankCol) String(wb *WorkBook) []string {
return []string{""}
}