github.com/shakinm/xlsReader@v0.9.12/xls/record/mulblank.go (about) 1 package record 2 3 import ( 4 "encoding/binary" 5 "github.com/shakinm/xlsReader/helpers" 6 ) 7 8 //MULBLANK: Multiple Blank Cells 9 10 var MulBlankRecord = []byte{0xBE, 0x00} // (BEh) 11 12 /* 13 The MULBLANK record stores up to the equivalent of 256 BLANK records; the 14 MULBLANK record is a file size optimization. The number of ixfe fields can be 15 etermined from the ColLast field and is equal to ( colLast-colFirst+1 ). The 16 maximum length of the MULBLANK record is (256x2+10)=522 bytes, because Excel 17 can have at most 256 columns. Note: storing 256 blank cells in the MULBLANK 18 record takes 522 bytes as compared with 2,560 bytes for 256 BLANK records. 19 20 Record Data 21 Offset Name Size Contents 22 -------------------------------------------- 23 4 rw 2 Row number (0-based) 24 6 colFirst 2 Column number (0-based) of the first column of the 25 multiple RK record 26 8 rgixfe var Array of indexes to XF records 27 10 colLast 2 Last column containing the BLANKREC structure 28 */ 29 30 type MulBlank struct { 31 rw [2]byte 32 colFirst [2]byte 33 rgixfe [][2]byte 34 colLast [2]byte 35 } 36 37 38 func (r *MulBlank) GetArrayBlRecord() (blkRecords []Blank) { 39 40 for k, rgixfe := range r.rgixfe { 41 var bl Blank 42 bl.rw = r.rw 43 binary.LittleEndian.PutUint16(bl.col[:], uint16(k)+helpers.BytesToUint16(r.colFirst[:])) 44 bl.ixfe=rgixfe 45 blkRecords= append(blkRecords, bl) 46 } 47 48 return 49 } 50 51 func (r *MulBlank) Read(stream []byte) { 52 copy(r.rw[:], stream[:2]) 53 copy(r.colFirst[:], stream[2:4]) 54 copy(r.colLast[:], stream[len(stream)-2:]) 55 56 cf := helpers.BytesToUint16(r.colFirst[:]) 57 cl := helpers.BytesToUint16(r.colLast[:]) 58 for i := 0; i <= int(cl-cf); i++ { 59 sPoint := 4 + (i * 2) 60 var indexXF [2]byte 61 copy(indexXF[:], stream[sPoint:sPoint+2]) 62 r.rgixfe = append(r.rgixfe, indexXF) 63 } 64 65 }