github.com/shakinm/xlsReader@v0.9.12/xls/record/xf.go (about) 1 package record 2 3 import "github.com/shakinm/xlsReader/helpers" 4 5 //XF: Extended Format (E0h) 6 7 var XFRecord = []byte{0xE0, 0x00} //(E0h) 8 9 /* 10 11 The XF record stores formatting properties. There are two different XF records, one 12 for cell records and another for style records. The fStyle bit is true if the XF is a 13 style XF . The ixfe of a cell record ( BLANK , LABEL , NUMBER , RK , and so on) points 14 to a cell XF record, and the ixfe of a STYLE record points to a style XF record. 15 Note: in previous BIFF versions, the record number for the XF record was 43h. 16 Prior to BIFF5, all number format information was included in FORMAT records in the 17 BIFF file. Beginning with BIFF5, many of the built-in number formats were moved to 18 an internal table and are no longer saved with the file as FORMAT records. Use the 19 ifmt to associate the built-in number formats with an XF record. However, the 20 internal number formats are no longer visible in the BIFF file. 21 The following table lists all the number formats that are now maintained internally. 22 Note: 17h through 24h are reserved for international versions and are 23 undocumented at this time. 24 25 Index to internal 26 format (ifmt) Format string 27 ------------------------------------- 28 00h General 29 01h 0 30 02h 0.00 31 03h #,##0 32 04h #,##0.00 33 05h ($#,##0_);($#,##0) 34 06h ($#,##0_);[Red]($#,##0) 35 07h ($#,##0.00_);($#,##0.00) 36 08h ($#,##0.00_);[Red]($#,##0.00) 37 09h 0% 38 0ah 0.00% 39 0bh 0.00E+00 40 0ch # ?/? 41 0dh # ??/?? 42 0eh m/d/yy 43 0fh d-mmm-yy 44 10h d-mmm 45 11h mmm-yy 46 12h h:mm AM/PM 47 13h h:mm:ss AM/PM 48 14h h:mm 49 15h h:mm:ss 50 16h m/d/yy h:mm 51 25h (#,##0_);(#,##0) 52 26h (#,##0_);[Red](#,##0) 53 27h (#,##0.00_);(#,##0.00) 54 28h (#,##0.00_);[Red](#,##0.00) 55 29h _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_) 56 2ah _($* #,##0_);_($* (#,##0);_($* "-"_);_(@_) 57 2bh _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_) 58 2ch _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_) 59 2dh mm:ss 60 2eh [h]:mm:ss 61 2fh mm:ss.0 62 30h ##0.0E+0 63 31h @ 64 65 A BIFF file can contain as many XF records as are necessary to describe the different 66 cell formats and styles in a workbook. The XF records are written in a table in the 67 workbook ( Book ) stream, and the index to the XF record table is a 0-based number 68 called ixfe . 69 The workbook stream must contain a minimum XF table consisting of 15 style XF 70 records and one cell XF record ( ixfe=0 through ixfe=15 ). The first XF record 71 ( ixfe=0 ) is the XF record for the Normal style. The next 14 records ( ixfe=1 72 through ixfe=14 ) are XF records that correspond to outline styles RowLevel_1, 73 ColLevel_1, RowLevel_2, ColLevel_2, and so on. The last record ( ixfe=15 ) is the 74 default cell XF for the workbook. 75 Following these XF records are five additional style XF records (not strictly required) 76 that correspond to the Comma, Comma [0], Currency, Currency [0], and Percent 77 styles. 78 79 80 Cell XF Record — BIFF8 81 Record Data 82 Offset Bits Mask Name Contents 83 -------------------------------------------------------- 84 4 15–0 FFFFh ifnt Index to the FONT record. 85 6 15–0 FFFFh ifmt Index to the FORMAT record. 86 8 0 0001h fLocked =1 if the cell is locked 87 1 0002h fHidden =1 if the cell is hidden. 88 2 0004h fStyle =0 for cell XF. 89 =1 for style XF. 90 3 0008h f123Prefix If the Transition Navigation Keys option is off (Options dialog box, 91 Transition tab), f123Prefix=1 indicates that a leading apostrophe 92 (single quotation mark) is being used to coerce the cell‘s contents to a 93 simple string. If the Transition Navigation Keys option is on, f123Prefix=1 indicates 94 that the cell formula begins with one of the four Lotus 1-2-3 alignment 95 prefix characters: 96 ' left 97 " right 98 ^ centered 99 \ fill 100 This bit is always 0 if fStyle=1 . 101 15–4 FFF0h ixfParent Index to the XF record of the parent style. Every cell XF must have a 102 parent style XF , which is usually ixfeNormal=0 T his structure is always FFFh if fStyle=1 . 103 10 2–0 0007h alc Alignment: 104 0= general 105 1= left 106 2= center 107 3= right 108 4= fill 109 5= justify 110 6= center across selection 111 3 0008h fWrap =1 wrap text in cell. 112 6–4 0070h alcV Vertical alignment: 113 0= top 114 1= center 115 2= bottom 116 3= justify 117 7 0080h fJustLast (Used only in East Asian versions of Excel). 118 15–8 FF00h trot Rotation, in degrees; 0–90dec is up 0–90 deg., 91–180dec is down 1–90 119 deg, and 255dec is vertical. 120 12 3–0 000Fh cIndent Indent value (Format Cells dialog box, Alignment tab) 121 4 0010h fShrinkToFit =1 if Shrink To Fit option is on 122 5 0020h fMergeCell =1 if Merge Cells option is on (Format Cells dialog box, Alignment tab). 123 7–6 00C0h iReadOrder Reading direction (East Asian versions only): 124 0= Context 125 1= Left-to-right 126 2= Right-to-left 127 9–8 0300h (Reserved) 128 10 0400h fAtrNum =1 if the ifmt is not equal to the ifmt of the parent style XF . 129 This bit is N/A if fStyle=1 . 130 11 0800h fAtrFnt =1 if the ifnt is not equal to the ifnt of the parent style XF . 131 This bit is N/A if fStyle=1 . 132 12 1000h fAtrAlc =1 if either the alc or the fWrap structure is not equal to the corresponding structure 133 of the parent style XF . This bit is N/A if fStyle=1 . 134 13 2000h fAtrBdr =1 if any border line structure ( dgTop , and so on) is not equal to the 135 corresponding structure of the parent style XF. This bit is N/A if fStyle=1 . 136 14 4000h fAtrPat =1 if any pattern structure ( fls , icvFore , icvBack ) is not equal to 137 the corresponding structure of the parent style XF . This bit is N/A if fStyle=1 . 138 15 8000h fAtrProt =1 if either the fLocked structure or the fHidden structure is not equal to the 139 corresponding structure of the parent style XF. This bit is N/A if fStyle=1. 140 14 3–0 000Fh dgLeft Border line style (see the following table). 141 7–4 00F0h dgRight Border line style (see the following table). 142 11–8 0F00h dgTop Border line style (see the following table). 143 15–12 F000h dgBottom Border line style (see the following table). 144 16 6–0 007Fh icvLeft Index to the color palette for the left border color. 145 13–7 3F80h icvRight Index to the color palette for the right border color. 146 15–14 C000h grbitDiag 1=diag down, 2=diag up, 3=both. 147 18 6–0 0000007Fh icvTop Index to the color palette for the top border color. 148 13–7 00003F80h icvBottom Index to the color palette for the bottom border color. 149 20–14 001FC000h icvDiag for diagonal borders. 150 24–21 01E00000h dgDiag Border line style (see the following table). 151 25 02000000h fHasXFExt =1 when a subsequent XFEXT record may modify the properties of this XF. 152 New for Office Excel 2007 153 31–26 FC000000h fls Fill pattern. 154 22 6–0 007Fh icvFore Index to the color palette for the foreground color of the fill pattern. 155 13–7 3F80h icvBack Index to the color palette for the background color of the fill pattern. 156 14 4000h fSxButton =1 if the XF record is attached to a PivotTable button. This bit is always 0 if fStyle=1 . 157 15 8000h (Reserved) 158 159 */ 160 161 type XF struct { 162 font [2]byte 163 format [2]byte 164 ttype [2]byte 165 } 166 167 func (r *XF) Read(stream []byte) { 168 copy(r.font[:], stream[0:2]) 169 copy(r.format[:], stream[2:4]) 170 copy(r.ttype[:], stream[4:6]) 171 172 } 173 174 func (r *XF) GetFormatIndex() int { 175 return int(helpers.BytesToUint16(r.format[:])) 176 }