github.com/shakinm/xlsReader@v0.9.12/xls/record/mulRk.go (about) 1 package record 2 3 import ( 4 "encoding/binary" 5 "github.com/shakinm/xlsReader/helpers" 6 "github.com/shakinm/xlsReader/xls/structure" 7 ) 8 9 // MULRK: Multiple RK Cells 10 11 var MulRKRecord = []byte{0xBD, 0x00} // (BDh) 12 13 /* 14 The MULRK record stores up to the equivalent of 256 RK records; the MULRK record is 15 a file size optimization. The number of 6-byte RKREC structures can be determined 16 from the ColLast field and is equal to (colLast-colFirst+1) . The maximum 17 length of the MULRK record is (256x6+10)=1546 bytes, because Excel has at most 18 256 columns. Note: storing 256 RK numbers in the MULRK record takes 1,546 bytes 19 as compared with 3,584 bytes for 256 RK records. 20 21 Record Data 22 Offset Name Size Contents 23 -------------------------------------------- 24 4 rw 2 Row number (0-based) 25 6 colFirst 2 Column number (0-based) of the first column of the 26 multiple RK record 27 8 rgrkrec var Array of 6-byte RKREC structures 28 10 colLast 2 Last column containing the RKREC structure 29 */ 30 31 type MulRk struct { 32 rw [2]byte 33 colFirst [2]byte 34 rgrkrec []structure.RKREC 35 colLast [2]byte 36 } 37 38 func (r *MulRk) GetArrayRKRecord() (rkRecords []Rk) { 39 40 for k, rkrec := range r.rgrkrec { 41 var rk Rk 42 rk.rw = r.rw 43 binary.LittleEndian.PutUint16(rk.col[:], uint16(k)+helpers.BytesToUint16(r.colFirst[:])) 44 rk.ixfe = rkrec.Ixfe 45 rk.rk = rkrec.RK 46 rkRecords = append(rkRecords, rk) 47 } 48 49 return 50 } 51 52 func (r *MulRk) Read(stream []byte) { 53 copy(r.rw[:], stream[:2]) 54 copy(r.colFirst[:], stream[2:4]) 55 copy(r.colLast[:], stream[len(stream)-2:]) 56 57 cf := helpers.BytesToUint16(r.colFirst[:]) 58 cl := helpers.BytesToUint16(r.colLast[:]) 59 for i := 0; i <= int(cl-cf); i++ { 60 sPoint := 4 + (i * 6) 61 var rkRec structure.RKREC 62 copy(rkRec.Ixfe[:], stream[sPoint:sPoint+2]) 63 copy(rkRec.RK[:], stream[sPoint+2:sPoint+6]) 64 r.rgrkrec = append(r.rgrkrec, rkRec) 65 } 66 67 }