[Standard Information] Excel File Format

xiaoxiao2021-03-06  42

MICROSOFT EXCEL FILE FORMAT Microsoft Excel is a popular spreadsheet. It uses a file format called BIFF (BinaryFile Format). There are many types of BIFF records. Each has a 4 byte header. Thefirst two bytes are an opcode that specifies the record type. . The second two bytesspecify record length header values ​​are stored in byte-reversed form (less significantbyte first) The rest of the record is the data itself (Figure 2-1) .Figure 2-1 BIFF record header |... Record header | Record Bodybyte Number | 0 1 2 3 | 0 1 ... ----------------------------------- Record Contents | XX | XX | XX | XX | XX | XX | ... --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- | opcode | length |. data Each X represents a hexadecimal digitTwo X's form a byte The least significant (low) byte of the opcode is byte 0 and themost significant (high) byte is byte 1. Similarly, the low byte of The record lengthfield is byte 2 and the high byte is byte 3.

Bof (Beginning Of File) The First Record in Every Spreadsheet IS Always of The Bof Type (Figure 2-2). Figure 2-2. Bof Record. | Record Header | Record Body | BYTE | 0 1 2 3 | 0 1 2 3 | ---------------------------------------- CONTENTS | 09 | 00 | 04 | 00 | 02 | 00 | 10 | 00 | --------------------------------------------------------------------------------------------------------------------------------------------- - | opcode | length | version | file | | | | number | type | The first two bytes, arranged with the low byte first, show that the opcode for BOF is09h The second two bytes indicate that the record body is 4 bytes. The first twobytes of the body is the version of excel (2 for the initial version of excel). The lasttwo bytes are the file type. Type 10h is a worksheet file.

Relating Spreadsheet Cells to Record Data BytesA spreadsheet appears on a screen or printout as a matrix of rectangular cells. Eachcolumn is identified by a letter at its top, and each row is identified by a number.Thus cell A1 is in the first column and the first row. Cell C240 ​​is in the third columnand the 240th row. This scheme identifies cells in a way easily understood by people.However, it is not particularly convenient for computers, as they do not handle lettersefficiently. They are best at dealing with binary numbers. Thus, Excel stores cellidentifiers as binary numbers, that people can read as hexadecimal. The first number inthe system is 0 rather than 1.Figure 2-3, which shows the form of an INTEGER record, illustrates the storage of columnand row information .

Figure 2-3. INTEger Record. | Record Header | Record Bodybyte | 0 1 2 3 | 0 1 2 3 4 5 6 7 8 | -------------------- --------------------------------------------- Value | 02 | 00 | 09 | 00 | 00 | 00 | 02 | 00 | 00 | 00 | 00 | 39 | 00 | -------------------------- ---------------------------------------- | Opcode | Length | ROW | Column | RGBATTR | w |. Opcode 2 indicates an integer record The length bytes show that the record body is 9bytes long Row 0 in the body corresponds to spreadsheet row 1. Row 1 corresponds tospreadsheet row 2, and so on column 2 corresponds to spreadsheet column.. C. Thus, Figure 2-3 Deals with cell c1. The next three Bytes, Labled "Rgbattr," Specify Cellattributes (Table 2-3). The final pair of bytes, (labeled "W") Holds the Integer'sValue. Here it is 39h or 57 decimal. Thus the recorded specifies That Cell C1 of the the value 57.standard file record ORDEREXCEL WORKSHEET FILES HAVE Each Record Type in a predetermined position. A file neednot have all types, but the ones that are present are always be in the same order.Table 2-1 lists the record types for Excel document (spreadsheet) files, in the orderthey would appear in a BIFF file. Table 2-2 lists the types in opcode order.Several record types in a BIFF file, namely, ROW, BLANK, INTEGER, NUMBER, LABEL, BOOLERR, FORMULA, and COLUMN DEFAULT, describe the contents of a cell. These recordscontain A 3 Byte Attribute Field Labled "Rgbattr"

. The following table describes howthe bits in the field correspond to cell attributes.Table 2-1. Cell AttributesByte Offset Bit Description Contents 0 7 Cell is not hidden 0b Cell is hidden 1b 6 Cell is not locked 0b Cell is locked 1b 5-0 Reserved, Must Be 0 000000B 7-6 Font Number (4 Possible) 5-0 Cell Format Code 2 7 Cell Is Not Shaded 0b Cell Is Shaded 1B 6 Cell Has NO BOTTOM BORDER 0B Cell Has A Bottom Border 1B 5 Cell Has NO TOP Border 0b Cell Has A Top Border 1B 4 Cell Has No Right Border 0b Cell Has A Right Border 1B 3 Cell Has No Left Border 0b Cell Has A LEFT BORDER 1B 2-0 Cell Alignment Code General 000B Left 001B Center 010b right 011b fill 100b Multiplan default align. 111bThe font number field is a zero-based index into the document's table of fonts. thecell format code is a zero-based index into the document's table of picture formats.There are 21 different standard formats. Additional Custom Formats May Be Defined Bythe User. See The Font and Format Record Descriptions form Additonal Details.

Table 2-2. Excel Record Type in Order of AppearanceRecord Type Opcode (Hexadecimal) BOF 09FILEPASS 2FINDEX 0BCALCCOUNT 0CCALCMODE 0DPRECISION 0EREFMODE 0FDELTA 10ITERATION 111904 22BACKUP 40PRINT ROW HEADERS 2APRINT GRIDLINES 2BHORIZONTAL PAGE BREAKS 1BVERTICAL PAGE BREAKS 1ADEFAULT ROW HEIGHT 25FONT 31FONT2 32HEADER 14FOOTER 15LEFT MARGIN 26RIGHT MARGIN 27TOP MARGIN 28BOTTOM MARGIN 29COLWIDTH 24EXTERNCOUNT 16EXTERNSHEET 17EXTERNNAME 23FORMATCOUNT 1FFORMAT 1ENAME 18DIMENSIONS 00COLUMN DEFAULT 20ROW 08BLANK 01INTEGER 02NUMBER 03LABEL 04BOOLERR 05FORMULA 06ARRAY 21CO NTINUE 3CSTRING 07TABLE 36TABLE2 37PROTECT 12WINDOW PROTECT 19PASSWORD 13NOTE 1CWINDOW1 3DWINDOW2 3EPANE 41SELECTION 1DEOF 0ATable 2-3. Excel Record Types in Opcode OrderRecord Type Opcode (hexadecimal) DIMENSIONS 00BLANK 01INTEGER 02NUMBER 03LABEL 04BOOLERR 05FORMULA 06STRING 07ROW 08BOF 09EOF 0AINDEX 0BCALCCOUNT 0CCALCMODE 0DPRECISION 0EREFMODE 0FDELTA 10ITERATION 11PROTECT 12PASSWORD 13HE

转载请注明原文地址:https://www.9cbs.com/read-51925.html

New Post(0)