forked from shakinm/xlsReader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mulblank.go
64 lines (52 loc) · 1.72 KB
/
mulblank.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
package record
import (
"encoding/binary"
"github.com/chansen-p44/xlsReader/helpers"
)
//MULBLANK: Multiple Blank Cells
var MulBlankRecord = []byte{0xBE, 0x00} // (BEh)
/*
The MULBLANK record stores up to the equivalent of 256 BLANK records; the
MULBLANK record is a file size optimization. The number of ixfe fields can be
etermined from the ColLast field and is equal to ( colLast-colFirst+1 ). The
maximum length of the MULBLANK record is (256x2+10)=522 bytes, because Excel
can have at most 256 columns. Note: storing 256 blank cells in the MULBLANK
record takes 522 bytes as compared with 2,560 bytes for 256 BLANK records.
Record Data
Offset Name Size Contents
--------------------------------------------
4 rw 2 Row number (0-based)
6 colFirst 2 Column number (0-based) of the first column of the
multiple RK record
8 rgixfe var Array of indexes to XF records
10 colLast 2 Last column containing the BLANKREC structure
*/
type MulBlank struct {
rw [2]byte
colFirst [2]byte
rgixfe [][2]byte
colLast [2]byte
}
func (r *MulBlank) GetArrayBlRecord() (blkRecords []Blank) {
for k, rgixfe := range r.rgixfe {
var bl Blank
bl.rw = r.rw
binary.LittleEndian.PutUint16(bl.col[:], uint16(k)+helpers.BytesToUint16(r.colFirst[:]))
bl.ixfe = rgixfe
blkRecords = append(blkRecords, bl)
}
return
}
func (r *MulBlank) Read(stream []byte) {
copy(r.rw[:], stream[:2])
copy(r.colFirst[:], stream[2:4])
copy(r.colLast[:], stream[len(stream)-2:])
cf := helpers.BytesToUint16(r.colFirst[:])
cl := helpers.BytesToUint16(r.colLast[:])
for i := 0; i <= int(cl-cf); i++ {
sPoint := 4 + (i * 2)
var indexXF [2]byte
copy(indexXF[:], stream[sPoint:sPoint+2])
r.rgixfe = append(r.rgixfe, indexXF)
}
}