forked from shakinm/xlsReader
/
rk.go
74 lines (58 loc) · 1.44 KB
/
rk.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
package record
import (
"github.com/twominutestomidnight/xlsReader/helpers"
"github.com/twominutestomidnight/xlsReader/xls/structure"
"reflect"
)
// RK: Cell Value, RK Number
var RkRecord = []byte{0x7E, 0x02} //(7Eh)
/*
Excel uses an internal number type, called an RK number, to save memory and disk
space.
Record Data
Offset Name Size Contents
--------------------------------------------
4 rw 2 Row
6 col 2 Column
8 ixfe 2 Index to the XF record
10 rk 4 RK number (see the following description)
An RK number is either a 30-bit integer or the most significant 30 bits of an IEEE
number. The two LSBs of the 32-bit rk field are always reserved for RK type
encoding; this is why the RK numbers are 30 bits, not the full 32.
*/
type Rk struct {
rw [2]byte
col [2]byte
ixfe [2]byte
rk structure.RKNum
}
func (r *Rk) GetRow() [2]byte {
return r.rw
}
func (r *Rk) GetCol() [2]byte {
return r.col
}
func (r *Rk) GetFloat64() float64 {
return r.rk.GetFloat()
}
func (r *Rk) GetInt64() int64 {
return r.rk.GetInt64()
}
func (r *Rk) GetType() string {
return reflect.TypeOf(r).String()
}
func (r *Rk) GetString() (s string) {
return r.rk.GetString()
}
func (r *Rk) GetXFIndex() int {
return int(helpers.BytesToUint16(r.ixfe[:]))
}
func (r *Rk) Read(stream []byte) {
copy(r.rw[:], stream[:2])
copy(r.col[:], stream[2:4])
copy(r.ixfe[:], stream[4:6])
copy(r.rk[:], stream[6:10])
}
func (r *Rk) Get() *Rk {
return r
}