github.com/shakinm/xlsReader@v0.9.12/xls/record/index.go (about)

     1  package record
     2  
     3  import "github.com/shakinm/xlsReader/helpers"
     4  
     5  //INDEX: Index Record
     6  
     7  var IndexRecord = [2]byte{0x02, 0x0B} // (20Bh)
     8  
     9  /*
    10  Excel writes an INDEX record immediately after the BOF record for each worksheet
    11  substream in a BIFF file. For more information about the INDEX record
    12  
    13  Record Data — BIFF8
    14  Offset		Field Name		Size		Contents
    15  ------------------------------------------------
    16  4			(Reserved)		4			Reserved; must be 0 (zero)
    17  8			rwMic			4			First row that exists on the sheet
    18  12			rwMac			4			Last row that exists on the sheet, plus 1
    19  16			(Reserved)		4			Reserved; must be 0 (zero)
    20  20			rgibRw			var			Array of file offsets to the DBCELL records for each
    21  										block of ROW records. A block contains ROW records for up to 32 rows.
    22  
    23  Record Data — BIFF7
    24  Offset		Field Name		Size		Contents
    25  ------------------------------------------------
    26  4			(Reserved)		4			Reserved; must be 0 (zero)
    27  8			rwMic			2			First row that exists on the sheet
    28  10			rwMac			2			Last row that exists on the sheet, plus 1
    29  12			(Reserved)		4			Reserved; must be 0 (zero)
    30  16			rgibRw			var			Array of file offsets to the DBCELL records for each
    31  										block of ROW records. A block contains ROW records for up to 32 rows.
    32  
    33  The rwMic field contains the number of the first row in the sheet that contains a
    34  value or a formula that is referenced by a cell in some other row. Because rows (and
    35  columns) are always stored 0-based rather than 1-based (as they appear on the
    36  screen), cell A1 is stored as row 0, cell A2 is row 1, and so on. The rwMac field
    37  contains the 0-based number of the last row in the sheet, plus 1.
    38  
    39  */
    40  
    41  type Index struct {
    42  	reserved  [4]byte
    43  	rwMic     [4]byte
    44  	rwMac     [4]byte
    45  	reserved2 [4]byte
    46  	rgibRw    []byte
    47  }
    48  
    49  func (r *Index) GetMaxRow() uint32 {
    50  	return helpers.BytesToUint32(r.rwMac[0:0]) + 1
    51  }
    52  
    53  func (r *Index) Read(stream []byte) {
    54  	copy(r.reserved[:], stream[:4])
    55  	copy(r.rwMic[:], stream[4:8])
    56  	copy(r.rwMac[:], stream[8:12])
    57  	copy(r.reserved2[:], stream[12:16])
    58  	copy(r.rgibRw, stream[16:])
    59  }