github.com/shakinm/xlsReader@v0.9.12/xls/record/sharedFormula.go (about) 1 package record 2 3 // SHRFMLA: Shared Formula 4 5 var SharedFormulaRecord = []byte{0xBC, 0x00} // (BCh) 6 7 /* 8 The SHRFMLA record is a file size optimization. It is used with the FORMULA record to 9 compress the amount of storage required for the parsed expression ( rgce ). In 10 earlier versions of Excel, if you read a FORMULA record in which the rgce field 11 contained a ptgExp parse token, the FORMULA record contained an array formula. 12 In Excel 5.0 and later, this could indicate either an array formula or a shared 13 formula. 14 If the record following the FORMULA is an ARRAY record, the FORMULA record 15 contains an array formula. If the record following the FORMULA is a SHRFMLA record, 16 the FORMULA record contains a shared formula. You can also test the fShrFmla bit 17 in the FORMULA record‘s grbit field to determine this. 18 When reading a file, you must convert the FORMULA and SHRFMLA records to an 19 equivalent FORMULA record if you plan to use the parsed expression. To do this, 20 take all of the FORMULA record up to (but not including) the cce field, and then 21 append to that the SHRFMLA record from its cce field to the end. You must then 22 convert some ptg s; this is explained later in this article. 23 Following the SHRFMLA record are one or more FORMULA records containing ptgExp 24 tokens that have the same rwFirst and colFirst fields as those in the ptgExp in 25 the first FORMULA . There is only one SHRFMLA record for each shared-formula 26 record group. 27 To convert the ptg s, search the rgce field from the SHRFMLA record for any 28 ptgRefN , ptgRefNV , ptgRefNA , ptgAreaN , ptgAreaNV , or ptgAreaNA tokens. 29 Add the corresponding FORMULA record‘s rw and col fields to the rwFirst and 30 colFirst fields in the ptg s from the SHRFMLA . Finally, convert the ptg s as shown 31 in the following table. 32 33 Convert 34 this ptg To this ptg 35 ------------------------------- 36 ptgRefN ptgRef 37 ptgRefNV ptgRefV 38 ptgRefNA ptgRefA 39 ptgAreaNV ptgArea 40 ptgAreaNA ptgAreaA 41 42 Remember that STRING records can appear after FORMULA records if the formula 43 evaluates to a string. 44 If your code writes a BIFF file, always write standard FORMULA records; do not 45 attempt to use the SHRFMLA optimization. 46 47 Record Data 48 Offset Name Size Contents 49 -------------------------------------------- 50 4 rwFirst 2 First row 51 6 rwLast 2 Last row 52 8 colFirst 1 First column 53 9 colLast 1 Last column 54 10 (Reserved) 2 55 12 cce 2 Length of the parsed expression 56 14 rgce var Parsed expression 57 58 */ 59 60 type ShareFormula struct { 61 RwFirst [2]byte 62 RwLast [2]byte 63 ColFirst [1]byte 64 ColLast [1]byte 65 Reserved [2]byte 66 Cce [2]byte 67 Rgce []byte 68 }