WORKSHEET FILE FORMAT
FROM LOTUS

INTRODUCTION AND QUICK REFERENCE

Copyright © 1984, Lotus Development Corporation
161 First Street
Cambridge, Massachusetts 02142
(617) 492-7171
Electronic Edition, December, 1984
All Rights Reserved

PREFACE

Lotus Development Corporation's 1-2-3(TM) and Symphony(TM) perform user selected operations upon a data matrix that is termed a "worksheet".

Worksheet files are such matrices stored on disk.

A worksheet file is an unbroken sequence of binary coded records defining a single worksheet.

Both 1-2-3 and Symphony accept externally created data files if the files are in the worksheet file format. Other programs can decode and process worksheet files created by 1-2-3 or Symphony.

The following document provides information required to create or access a worksheet file by describing the records used to create a worksheet file. It is assumed that the reader is familiar with Lotus products and has ready access to 1-2-3 or Symphony documentation.

Note that the worksheet files for 1-2-3 and Symphony are similar, but not necessarily interchangeable. 1-2-3 and Symphony share some record types, but also have record types unique to that product. Symphony can read 1-2-3 records, but 1-2-3 cannot read Symphony records.

The information contained in this document has been released into the public domain and is not considered to be confidential or proprietary although still the copyright and property of Lotus Development Corporation. All efforts have been made to ensure that this information is clear and useful since Lotus will not be providing customer assistance with this booklet. Lotus will, however, incorporate any necessary corrections if they are reported in writing to:

Lotus Development Corporation
Worksheet File Format
161 First Street
Cambridge, MA 02142

WORKSHEET FILE FORMAT

Worksheet files are organized as an unbroken sequence of variable length binary records. Each record consists of a 4-byte header followed by the record body. The header defines the record's type and length, as the example below shows.

The header's composition is as follows:

Byte NumberByte Description
0,1Record type code
2,3Record body length (bytes)

Example: Record Header

RecordRecord
TypeLength
Byte Number00 0102 03
Hex Code1C 0020 00
Decimal Equivalent2832

The record body can be of many different types; most have predetermined length, but some vary in length.

The record type code is 28.

In a hex dump of the file, the record type appears as 1C 00h, noting that the 8086/88 stores the most significant byte of word in the higher memory address.

The record length is 32 bytes. In a hex dump of the file, the record length appears as 20 00h.

Record types with Column/Row Coordinates

Some record types contain column/row coordinates to identify a cell, or one of the two points that define a range. Numbering starts at zero in the upper left corner of the worksheet. For example:

Cell A1 = column 0, row 0


SUMMARY OF RECORD TYPES

This section describes the different record types found in 1-2-3 and Symphony.

There are to Quick Reference tables ordered by Opcode and by Product, followed by a detailed reference section ordered by Opcode. In the reference section, there are examples for the more commonly used records.

It is assumed that the reader is familiar with 1-2-3 or Symphony and has access to Lotus' documentation.

Quick Reference by Opcode

TypeCode (hex)Length (bytes)Description
BOF02Beginning of file
EOF10End of file
CALCMODE21Calculation mode
CALCORDER31Calculation order
SPLIT41Split window type
SYNC51Split window sync
RANGE68Active worksheet range
WINDOW1731Window 1 record
COLW183Column width, window 1
WINTWO931Window 2 record
COLW2A3Column width, window 2
NAMEB24Named range
BLANKC5Blank cell
INTEGERD7Integer number cell
NUMBERE13Floating point number
LABELFvariableLabel cell
FORMULA10variableFormula cell
TABLE1825Data table range
ORANGE1925Query range
PRANGE1A8Print range
SRANGE1B8Sort range
FRANGE1C8Fill range
KRANGE11D9Primary sort key range
HRANGE2016Distribution range
KRANGE2239Secondary sort key range
PROTEC241Global protection
FOOTER25242Print footer
HEADER26242Print header
SETUP2740Print setup
MARGINS2810Print margins code
LABELFMT291Label alignment
TITLES2A16Print borders
GRAPH2D437Current graph settings
NGRAPH2E453Named graph settings
CALCCOUNT2F1Iteration count
UNFORMATTED301Formatted/unformatted print
CURSORW12311Cursor location
WINDOW32144Symphony window settings
STRING33variableValue of string formula
PASSWORD374File lockout (CHKSUM)
LOCKED381Lock flag
QUERY3C127Symphony query settings
QUERYNAME3D16Query name
PRINT3E679Symphony print record
PRINTNAME3F16Print record name
GRAPH240499Symphony graph record
GRAPHNAME4116Graph record name
ZOOM429Orig coordinates expanded window
SYMSPLIT432Nos. of split windows
NSROWS442Nos. of screen rows
NSCOLS452Nos. of screen columns
RULER4625Named ruler range
NNAME4725Named sheet range
ACOMM4865Autoload.comm code
AMACRO498Autoexecute macro address
PARSE4A16Query parse information

Quick Reference by Product: 1-2-3 only

TypeCode (hex)Length (bytes)Description
SPLIT41Split window type
SYNC51Split window sync
WINDOW1731Window 1 record
WINTWO931Window 2 record
COLW2A3Column width, window 2
NAMEB24Named range
QRANGE1925Query range
PRANGE1A8Print range
SRANGE1B8Sort range
KRANGE11D9Primary sort key range
KRANGE2239Secondary sort key range
FOOTER25242Print footer
HEADER26242Print header
SETUP2740Print setup
MARGINS2810Print margins code
TITLES2A16Print borders
GRAPH2D437Current graph settings
NGRAPH2E453Named graph settings

Quick Reference by Product: 1-2-3 and Symphony

TypeCode (hex)Length (bytes)Description
BOF02Beginning of file
EOF10End of file
CALCMODE21Calculation mode
CALCORDER31Calculation order
RANGE68Active worksheet range
COLW183Column width
BLANKC5Blank cell
INTEGERD7Integer number cell
NUMBERE13Floating point number
LABELFvariableLabel cell
FORMULA10variableFormula cell
TABLE1825Data table range
FRANGE1C8Fill range
HRANGE2016Distribution range
PROTEC241Global protection
LABELFMT291Label alignment
CALCCOUNT2F1Iteration count
UNFORMATTED301Formatted/unformatted print
CURSORW12311Cursor location

Quick Reference by Product: Symphony only

TypeCode (hex)Length (bytes)Description
WINDOW32144Symphony window settings
STRING33variableValue of string formula
PASSWORD374File lockout (CHKSUM)
LOCKED381Lock flag
QUERY3C127Symphony query settings
QUERYNAME3D16Query name
PRINT3E679Symphony print record
PRINTNAME3F16Print record name
GRAPH240499Symphony graph record
GRAPHNAME4116Graph rocord name
ZOOM429Orig coordinates expanded window
SYMSPLIT432Nos. of split windows
NSROWS442Nos. of screen rows
NSCOLS452Nos. of screen columns
RULER4625Named ruler range
NNAME4725Named sheet range
ACOMM4865Autoload. comm code
AMACRO498Autoexecute macro address
PARSE4A16Query parse information


SUMMARY OF RECORD TYPES

BOF

Record TypeCodeBody length
BOF0 (00H)2 bytes

Record Description: Beginning of file

Used by both 1-2-3 and Symphony.

Byte NumberByte Description
0-1file format revision number
1028 (0404h) = 1-2-3 file
1029 (0405h) = Symphony file

Example

                           Record Header             Record Body

                        Record        Record              BOF
                         Type         Length
 Byte Number            0    1        2    3             0   1
    Hex Code           00   00       02   00            04  04
 Dec.Equivalent           0             2                1028

EOF

Record TypeCodeBody length
EOF1 (01H)0 bytes

Record Description: End of file

Used by both 1-2-3 and Symphony

Byte NumberByte Description
-no record body-

Example

                           Record Header

                      Record          Record
                       Type           Length
      Byte Number     0    1          2    3
        Hex Code     01    00        00   00
 Decimal Equivalent     1               0

Note: End of file is ony a header. EOF has a record length of 0; therefore, no record body follows.

CALCMODE

Record TypeCodeBody length
CALCMODE2 (02h)1 byte

Record Description: Calculation method

Used by both 1-2-3 and Symphony.

Byte NumberByte Description
00 = Manual mode
FF = automatic

CALCORDER

Record TypeCodeBody length
CALCORDER3 (03H)1 BYTE

Record Description: Calculation order

Used by both 1-2-3 and Symphony

Byte NumberByte Description
00 = natural
1 = by column
FF = by row

SPLIT

Record TypeCodeBody length
SPLIT4(04h)1 byte

Record Description: Split window type

Used in 1-2-3 only.

Byte NumberByte Description
00 = not split
1 = vertical split
FF = horizontal split

SYNC

Record TypeCodeBody length
SYNC5(05h)1 byte

Record Description: Split window sync

This determines whether the two screens in 1-2-3's split-screen feature will move together with the cursor.

Used in 1-2-3 only.

Byte NumberByte Description
00 = not synchronized
FF = synchronized

RANGE

Record TypeCodeBody length
RANGE6(06h)8 bytes

Record Description:

Range of cells written to worksheet file. If the worksheet file was created using a File Save command, then this range describes the active area with trailing blank columns and rows removed. If the worksheet file was created using a File Xtract command, then this range describes the extract range with trailing blank columns and rows removed. If there is no data in the range, the starting column is set to -1.

Used by both 1-2-3 and Symphony.

Byte NumberByte Description
0-1starting column
2-3starting row
4-5ending column
6-7ending row

Example

                   Record Header             rt_range Record Body 
Record Record Starting Starting Ending Ending
Type Length Column Row Column Row
Byte Number 0 1 2 3 0 1 2 3 4 5 6 7 Hex Code 06 00 08 00 00 00 00 00 01 00 03 00
Dec.Equivalent 6 8 0 0 1 3

The record displays the worksheet range as A1...B4.

WINDOW1

Record TypeCodeBody length
WINDOW17(07h)31 bytes

Record Description: Window 1 record

Used in 1-2-3 only.

Byte NumberByte Description
0-1cursor column position
2-3cursor row position
4format (see Appendix A, Cell Format Encoding)
5unused (0)
6-7column width
8-9number of columns on screen
10-11number of rows on screen
12-13left column
14-15top row
16-17number of title columns
18-19number of title rows
20-21left title column
22-23top title row
24-25border width column
26-27border width row
28-29window width
30unused (0)

COLW1

Record TypeCodeBody length
COLW18(08h)3 bytes

Record Type Description

Column width Used by both 1-2-3 and Symphony.

In 1-2-3, this record contains the width of a column Window 1. In symphony, it contains width information for the Window Record that it follows.

Byte NumberByte Description
0-1column
2width

WINTWO

Record TypeCodeBody length
WINTWO9(09h)31 bytes

Record Description: Window 2 record

Used in 1-2-3 only.

Byte NumberByte Description
0-1cursor column position
2-3cursor row position
4format (see Appendix A, Cell Format Encoding)
5unused (0)
6-7column width
8-9number of columns on screen
10-11number of rows on screen
12-13left column
14-15top row
16-17number of title columns
18-19number of title rows
20-21left titile column
22-23top title row
24-25border width column
26-27border width row
28-29window width
30unused (0)

COLW2

Record TypeCodeBody length
COLW210(0Ah)3 bytes

Record Description: Column width, Window 2

Used in 1-2-3 only.

Byte NumberByte Description
0-1column
2width

NAME

Record TypeCodeBody length
NAME11 (OBh)24 bytes

Record Description: Name of range

The worksheet contains one record for each range name. Used in 1-2-3 only.

Byte NumberByte Description
0-15NULL terminated ASCII string
16-17Starting column
18-19Starting row
20-21Ending column
22-23 Ending row

Example

                           Record Header
                        Record      Record
                         Type       Length
 Byte Number            0    1      2    3
 Hex Code              0B   00     18   00
 Decimal Equivalent       11          24

                           Record Body
                        Range Name (Text)
            Decimal Equivalent Expressed in ASCII Text
      0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
     52 45 56 45 4E 55 45 53 00 00  00  00  00  00  00  00
     R  E  V  E  N  U  E  S /    Unfilled  Names   Area

    (cont.)                Record Body

                Starting  Starting  Ending  Ending
                Column      Row     Column    Row
                16  17     18  19   20  21  22  23
                00  00     00  00   01  00  03  00
                   0         0        1        3

Range name is REVENUES (encompasses A1 to B4).

BLANK

Record TypeCodeBody length
BLANK12(0Ch)5 bytes

Record Description: Blank cell

Blank cell records appear only for those cells that are protected, or do not have the default format.

Unprotected blank cells with the default format are omitted from the worksheet file.

Used by both 1-2-3 and Symphony.

Byte NumberByte Description
0format (see Appendix A, Cell Format Encoding)
1-2column
3-4row

Example

                      Record Header              Record Body
                  Record         Record
                   Type          Length      Format    Column     Row
 Byte Number      0    1         2    3         0      1    2    3   4
 Hex Code        0C   00        05   00        22     05   00   0A  00
 Dec. Equivalent    12             5           34        5        10
 

This record displays cell in location F11 (column 5, row 10).

INTEGER

Record TypeCodeBody length
INTEGER13(ODh)7 bytes

Record Description: Integer number cell

An integer cell holds a single integer value in the range -32767....+32767 (decimal).

Used by both 1-2-3 and Symphony.

Byte NumberByte Description
0format (see Appendix A, Cell Format Encoding)
1-2column
3-4row
5-6integer value

Example

                  Record Header                      Record Body
                Record     Record
                 Type      Length         Format   Column    Row    Integer
 Byte Number    0    1     2    3            0     1    2    3  4    5   6
 Hex Code      0D   00    07   00           00    00   00   00 00   DD  04
 Dec. Equivalent  13        7                0       0        0      1245
 

This example displays the integer 1245 located in cell A1 (column 0, row 0). When reading a 2-byte integer, the lower byte appears first. For example, DD04h is actually 04DDh (1245 decimal).

NUMBER

Record TypeCodeBody length
NUMBER14 (0Eh)13 bytes

Record Description: Floating point number

Used by both 1-2-3 and Symphony

Byte NumberByte Description
0format
1-2column
3-4row
5-12value(IEEE long real; 8087 double-precision floating-point format)

Example The following describes a 64-bit long real format.

                   S           Exponent           Fraction
                  63          62      52          51       0
                  MSB                                    LSB

 S                1-bit Sign field
                  0 = +
                  1 = -

 Exponent         11-bit Exponent field
 

Exponent is binary, excess 1023(base 10). Thus, the true exponent is: 2^(exponent -1023).

 Fraction         52-bit Fraction field
 

An implied leading 1 bit is at the beginning of the fraction. The implied binary point is between the implied 1 bit and the Most Significant Bit (MSB) of the fraction field.

 Special             NA:  S = 1 Exponent = 7FF Fraction = 0
 Values             ERR:  S = 0 Exponent = 7FF Fraction = 0

                 STRING:  S = 0 Exponent = 7FF Fraction = non-zero
                                               (Symphony only)

LABEL

Record TypeCodeBodylength
LABEL15(0Fh)variable

Record Description: Label cell

Used by both 1-2-3 and Symphony.

Byte NumberByte Description
0format (see Appendix A, Cell Format Encoding)
1-2column
3-4row
5+NULL terminated ASCII string; 240 bytes maximum

Example

                Record Header                     Record Body
               Record   Record
                Type    Length      Format  Column  Row        Label
 Byte Number    0  1     2  3          0     1  2   3  4   5  6  7  8  9 10
 Hex Code      0F 00    0B 00         F5    00 00  00 00  27 50 41 55 4C 00
 Dec. Equivalent 15       11         245      0      0       P  A  U  L
 

This example is a label record located at A1 (column 0, row 0).

This record contains the word 'PAUL. Byte 5 is always one of the following format prefixes:\'"^.

This record varies in relation to the amount of text stored in the cell.

A user can enter up to 240 characters in one cell.

FORMULA

Record TypeCodeBody length
FORMULA16(10H)variable

Record Description: Formula cell

Used by both 1-2-3 and Symphony.

Formulas are compiled in Reverse Polish Internal Notation. By creating formulas in 1-2-3 or Symphony, and dumping them as hex bytes, the formula compilation logic can be deciphered.

Table 1 describes the available Opcodes and functions. The functions are discussed in greater detail in the 1-2-3 and Symphony documentation.

Appendix B discusses Lotus' proprietary formula compiler in greater detail.

Byte NumberByte Description
0format (see Appendix A, Cell Format Encoding
1-2column
3-4row
5-12formula numeric value (IEEE long real; see NUMBER)
13-14formula size (bytes)
15+for code (see Table 1, Formula Opcodes); Reverse Polish Internal Notation; 2048 bytes maximum

Table 1-a Formula Compiler Opcode Table, Format

DecHexOperationDescription
00constantCode is followed by an 8 byte IEEE Long Real Floating Point Number
11variableCode followed by 4 byte coordinate
Byte 0,1 = Column
Byte 2,3 = Row
22rangeCode followed by 8 byte range
Byte 0,1 = Start column
Byte 2,3 = Start row
Byte 4,5 = End column
Byte 6,7 = End row
33returnEnd of formula
44parenthesesIndicates presence of parentheses in original formula. It is ignored during recalculation.
552 byte integerFollowed by 2 byte signed constant integer.

The above Opcodes will define the type and length of information that follows the Opcode. Opcode 3 defines the end of the formula.

For example:
Opcode 0 is followed by an 8 byte floating point number.
Opcode 1 is followed by a 4 byte coordinate.
Opcode 2 is followed by an 8 byte range specifier.
Opcode 5 is followed by a 2 byte signed integer.

Table 1-b Formula Compiler Opcode Table, Operations

DecHexOperationDescription
88unary -Negation
99+Addition
10A-Subtraction
11B*Multiplication
12C/Division
13D^Exponentiation; ie. 3^2 is(3x3)
14E=Equal to
15F< >Not equal to
1610< =Less than or equal to
1711> =Greater than or equal to
1812<Less than
1913>Greater than
2014#AND#Logical AND
2115#OR#Logical OR
2216#NOT#Logical NOT
2317unary +(Ignored during recalculation
311Fna@Na not applicable
3220err@Err error
3321abs@abs (x) Absolute value of x
3422int@int (x) Integer value of x
3523sqrt@sqrt (x) Square root of x
3624log@log (x) Log base 10 of x
3725ln@ln (x) Log base e of x
3826pi@pi
3927sin@sin (x) Sine of x
4028cos@cos (x) Cosine of x
4129tan@tan (x) Tangent of x
422Aatan2@atan2 (x) 4 quadrant arc tangent of x
432Batan@atan (x) 2 quadrant arc tangent of x
442Casin@asin (x) Arc sine of x
452Dacos@acos (x) Arc cosine of x
462Eexp@exp (x) Exponential anti-log of x
472Fmod@mod (x,y)X Mod Y
4830sel@Choose (x,v0,v1...vN) Match a list item.
4931isna@isna (x)x = NA then 1 (true)
5133false@false Return 0
5234true@true Return 1
5335rand@rand Generate random number between 0 and 1
5436date@date (Y,M,D) Generate the days since 1/1/1900 (Y = 0-199, M = 1-12, D = 1-31)
5537today@today Output serial date number from cpu's clock
5638pmt@pmt (princ, int, term)Payment
5739pv@pv (pmt, int, term) Present value
583Afv@fv (pmt, int, term) Future Value
593Bif@if (argument, them else) Boolean if
603Cday@day (x) Print day of the month from a serial date number
613Dmonth@month (x) Print month of the year from a serial date number
623Eround@round (x,d) Round number x to d decimal places

The above Opcodes are variable, constant and argument related.

For example:
@sqrt (9) is the square root of the constant 9
@sqrt (A1) is the square root of the variable A1
@sqrt ((A1*2)/3) is the square root of the argument (A1*2)/3
(Note that the argument ((A1*2)/3) will be processed before the @sqrt function.)

Table 1-c Formula Compiler Opcode Table, Multiple Arguments

DecHexOperationDescription
8050sum@sum (range and/or cell and/or constant) Use commas to separate arguments
8151avg@avg (range and/or cell and/or constant) Use commas to separate arguments
8252cnt@cnt (range and/or cell and/or constant) Use commas to separate arguments
8353min@min (range and/or cell and/or constant) Use commas to separate arguments
8454max@max (range and/or cell and/or constant Use commas to separate arguments
8555vlookup@Vlookup (x, range, offset) X = Cell address or constant, range = Table, Offset = Row in Table
8656npv@npv (int, range) Net present value; Int = interest, Range = cash flows
8757var@var (range) Variance of all items in list
8858std@std (range) Standard deviation of all items in list
8959irr@irr (guess,range) Guess = % estimate; Range = range of cash flows
905Ahlookup@hlookup, (x, range, offset) X = Cell address or constant, range = Table, Offseet = row in Table
915BdsumDatabase statistical functions
925CavgDatabase statistical functions
935DdcntDatabase statistical functions
945EdminDatabase statistical functions
955FdmaxDatabase statistical functions
9660dvarDatabase statistical functions
9761dstdDatabase statistical functions

The above Opcodes deal specifically with ranges and multiple arguments. For example: @sum (A1...A10, B25, 9) contains a range, a variable and a constant as the arguments.

All function Opcodes which accept a variable number of arguments are followed by a 1-byte argument count.

Table 1-d Operator Precedence Table

OperatorUnary PrecedenceBinary Precedence
+64
-64
*na5
/na5
^na7
=na3
< >na3
< =na3
> =na3
<na3
>na3
#and#na1
#or#na1
#not#2na

A Note on the Decompiler

The algorithm for the formula decompiler was taken verbatim from:

Writing Interactive Compilers and Interpreters, P.J. Brown, John Wiley and Sons, 1979. See chapter 6.2. The algorithm itself is described on pages 216 and 217.

This algorithm is also described in the following article:

More on the Re-creation of Source Code from Reserve Polish, P.J. Brown, Software Practice and Experience, Vol 7, 545-551 (1977).

TABLE

Record TypeCodeBody length
TABLE24 (18h)25 bytes

Record Description: Table range

Used by both 1-2-3 and Symphony. In 1-2-3, the record refers to Data Tables 1 and 2. In Symphony, it refers to What-if Tables 1 and 2.

Byte NumberByte Description
00 = no table
1 = Table 1
2 = Table 2
1-2Table Rangestarting column
3-4starting row
5-6ending column
7-8ending row
9-10Input Cell 1starting column
11-12starting row
13-14ending column
15-16ending row
17-18Input Cell 2starting column
19-20starting row
21-22ending column
23-24ending row

QRANGE

Record TypeCodeBody length
QRANGE25 (19h)25 bytes

Record Description: Query range

Used in 1-2-3 only.

Byte NumberByte Description
0-1Input rangesstarting column
2-3starting row
4-5ending column
6-7ending row
8-9Output rangesstarting column
10-11starting row
12-13ending column
14-15ending row
16-17Criteriastarting column
18-19starting row
20-21ending column
22-23ending row
24Command0 = no command
1 = find
2 = extract
3 = delete
4 = unique

PRANGE

Record TypeCodeBody length
PRANGE26 (1Ah)8 bytes

Record Description: Print range

Used in 1-2-3 only.

Byte NumberByte Description
0-1starting column
2-3starting row
4-5ending column
6-7ending row

SRANGE

Record TypeCodeBody length
SRANGE27 (1Bh)8 bytes

Record Description: Sort range

Used in 1-2-3 only.

Byte NumberByte Description
0-1starting column
2-3starting row
4-5ending column
6-7ending row

FRANGE

Record TypeCodeBody length
FRANGE28 (1Ch)8 bytes

Record Description: Fill range

Used by both 1-2-3 and Symphony.

Byte NumberByte Description
0-1starting column
2-3starting row
4-5ending column
6-7ending row

KRANGE

Record TypeCodeBody length
KRANGE29 (1Dh)9 bytes

Record Description: Primary sort key range

Used in 1-2-3 only.

Byte NumberByte Description
0-1starting column
2-3starting row
4-5ending column
6-7ending row
8Order: 0 = descending order
     FF = ascending order

HRANGE

Record TypeCodeBody length
HRANGE32 (20h)16 bytes

Record Description: Distribution range

Used by both 1-2-3 and Symphony.

Byte NumberByte Description
0-1Values rangestarting column
2-3starting row
4-5ending column
6-7ending row
8-9Bin rangestarting column
10-11starting row
12-13ending column
14-15ending row

KRANGE2

Record TypeCodeBody length
KRANGE235(23h)9 bytes

Record Description: Secondary sort key range

Use in 1-2-3 only.

Byte NumberByte Description
0-1starting column
2-3starting row
4-5ending column
6-7ending row
8Order; 0 = descending order
     FF = ascending order

PROTEC

Record TypeCodeBody length
PROTEC36(24h)1 byte

Record Description: Global protection

Used by both 1-2-3 and Symphony.

Byte NumberByte Description
00 = global protection OFF
1 = global protection ON

FOOTER

Record TypeCodeBody length
FOOTER37(25h)242 bytes

Record Description: Print footer

Used in 1-2-3 only.

Byte NumberByte Description
0-242NULL termination ASCII string

HEADER

Record TypeCodeBody length
HEADER38(26h)242 bytes

Record Description: Print header

Used in 1-2-3 only.

Byte NumberByte Description
0-242NULL terminated ASCII string

SETUP

Record TypeCodeBody length
SETUP39(27h)40 bytes

Record Description: Print setup

Used in 1-2-3 only.

Byte NumberByte Description
0-40NULL terminated ASCII string

MARGINS

Record TypeCodeBody length
MARGINS40(28h)10 bytes

Record Description: Print margins code

Used in 1-2-3 only.

Byte NumberByte Description
0-1left margin
2-3right margin
4-5page length
6-7top margin
8-9bottom margin

LABELFMT

Record TypeCodeBody length
LABELFMT41 (29h)1 byte

Record Description: Label alignment

Used by both 1-2-3 and Symphony

Byte NumberByte Description
027h = left
22h = right
5Eh = center

TITLES

Record TypesCodeBody length
TITLES42(2Ah)16 bytes

Record Description: Print borders

Used in 1-2-3 only.

Byte NumberByte Description
0-1Row borderstarting column
2-3starting row
4-5ending column
6-7ending row
8-9Column borderstarting column
10-11starting row
12-13ending column
14-15ending row

GRAPH

Record TypeCodeBody length
GRAPH45(2Dh)437 bytes

Record Description: Current graph settings

Used in 1-2-3 only.

Table 2 Graph Record Structure

Byte NumberByte Description
0-1X Rangestarting column
2-3starting row
4-5ending column
6-7ending row
8-9A Rangestarting column
10-11starting row
12-13ending column
14-15ending row
16-17B Rangestarting column
18-19starting row
20-21ending column
22-23ending row
24-25C Rangestating column
26-27starting row
28-29ending column
30-31ending row
32-33D Rangestarting column
34-35starting row
36-37ending column
38-39ending row
40-41E Rangestarting column
42-43starting row
44-45ending column
46-47ending row
48-49F Rangestarting column
50-51starting row
52-53ending column
54-55ending row
56-57A Labelsstarting column
58-59starting row
60-61ending column
62-63ending row
64-65B Labelsstarting column
66-67starting row
68-69ending column
70-71ending row
72-73C Labelsstarting column
74-75starting row
76-77ending column
78-79ending row
80-81D Labelsstarting column
82-83starting row
84-85ending column
86-87ending row
88-89E Labelsstarting column
90-91starting row
92-93ending column
94-95ending row
96-97F Labelsstarting column
98-97starting row
100-101ending column
102-103ending row
104Graph type0 = XY, 1 = bar, 2 = pie, 4 = line, 5 = stacked bar
105Grid0 = none, 1 = horizontal, 2 = vertical, 3 = both
106Color0 = black-white, FF = color
107A Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
108B Range line format0 = none, 1 = line, 2 = symbol, e = line-symbol
109C Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
110D Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
111E Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
112F Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
113A Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
114B Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
115C Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
116D Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
117E Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
118F Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
119Scale0 = auto, FF = manual
120-127X lower limit in floating point format
128-135X upper limit in floating point format
136Y scale0 = automatic, FF = manual
137-144Y lower limit in floating point format
145-152Y upper limit in floating point format
153-192First title
193-232Second title
233-272X title
273-312Y title
313-332A legend
333-352B legend
353-372C legend
373-392D legend
393-412E legend
413-432F legend
433X format
434Y format
435-436Skip factor

NGRAPH

Record TypeCodeBody length
NGRAPH46 (2EH)453 bytes

Record Description: Named current graph settings

Used in 1-2-3 only.

Table 3 NGraph Record Structure

Byte NumberByte Description
0-15NameNULL terminated ASCII string
16-17X Rangestarting column
18-19starting row
20-21ending column
22-23ending row
24-25A Rangestarting column
26-27starting row
28-29ending column
30-31ending row
32-33B Rangestarting column
34-35starting row
36-37ending column
38-39ending row
40-41C Rangestarting column
42-43starting row
44-45ending column
46-47ending row
48-49D Rangestarting column
50-51starting row
52-53ending column
54-55ending row
56-57E Rangestarting column
58-59starting row
60-61ending column
62-63ending row
64-65F Rangestating column
66-67starting row
68-69ending column
70-71ending row
72-73A Labelsstarting column
74-75starting row
76-77ending column
78-79ending row
80-81B Labelsstarting column
82-83starting row
84-85ending column
86-87ending row
88-89C Labelsstarting column
90-91starting row
92-93ending column
94-95ending row
96-97D Labelsstarting column
98-99starting row
100-101ending column
102-103ending row
104-105E Labelsstarting column
106-107starting row
108-109ending column
110-111ending row
112-113F Labelsstarting column
114-115starting row
116-117ending column
118-119ending row
120Graph type0 = XY, 1 = bar, 2 = pie, 4 = line, 5 = stacked bar
121Grid0 = none, 1 = horizontal, 2 = vertical, 3 = both
122Color0 = black-white, FF = color
123A Range line format0 = none, l = line, 2 = symbol, 3 = line-symbol
124B Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
125C Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
126D Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
127E Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
128F Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
129A Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
130B Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
131C Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
132D Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
133E Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
134F Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
135X scale0 = auto FF = manual
136-143X lower limit in floating point format
144-151X upper limit in floating point format
152Y scale0 = automatic FF = manual
153-160Y lower limit in floating point format
161-168Y upper limit in floating point format
209-224First title
225-248Second title
249-288X title
289-328Y title
329-348A legend
349-368B legend
369-388C legend
389-408D legend
409-428E legend
429-448F legend
449X format
450Y format
451-452Skip factor

CALCCOUNT

Record TypeCodeBody length
CALCCOUNT47(2Fh)1 byte

Record Description: Iteration count

Used in 1-2-3 and Symphony.

Byte NumberByte Description
0Iteration count

UNFORMATTED

Record TypeCodeBody length
UNFORMATTED48(30h)1 byte

Record Description: Formatted/unformatted print

Used in 1-2-3 only.

Byte NumberByte Description
00 = formatted
1 = unformatted

CURSORW12

Record TypeCodeBody length
CURSORW1249(31h)1

Record Description: Cursor location

Used in 1-2-3 only.

Byte NumberByte Description
01 = cursor in Window 1
2 = cursor in Window 2

WINDOW

Record TypeCodeBody length
WINDOW50(32h)144 bytes

Record Description: Window record structure

Used in Symphony only.

Table 4 Window Record Structure

Byte NumberByte Description
0-15Window nameNULL terminated ASCII string
16-17Cursor positioncolumn
18-19row
20Format(see Appendix A, Cell Format Encoding)
21Unused
22-23Column width
24-25Total number of columns
26-27Total number of rows
28-29Non-Title Home Positioncolumn
30-31row
32-33Number of title columns
34-35Number of title rows
36-37Left title column
38-39Top title row
40-41Home position column
42-43Home position row
44-45Number of screen columns
46-47Number of screen rows
48Hidden Status0 = hidden, FF = not hidden
49Previous window0 = SHEET, 1 = DOC, 2 = GRAPH, 3 = COMM, 4 = FORM, 5 = APPLICATION
50Border display0 = cell, FF = no cell
51Border display lines0 = lines, FF = no lines
52-53Window Rangestarting column
54-55starting row
56-57ending column
58-59ending row
60-61Offset
62Insert mode flag0 = OFF, non-zero = ON
63-78Graph name
79Window type0 = SHEET, 1 = DOC, 2 = GRAPH, 3 = COMM, 4 = FORM, 5 = APPLICATION
80Automatic display mode"a" = automatic, else = manual
81Forms filter0 = filter, non-zero = no filter
82-97Associated form name
98-99Forms current record
100Space display0 = no spaces, non-zero = spaces
101Line spacing1 = 1 space, 2 = 2 spaces, 3 = 3 spaces
102Justify type"l" = left, "r" = right, "c" = cent, "e" = even
103-104Right Margin0-FO characters = right margin
FF = no user-defined right margin; use default value
105-106Left Margin0-FO characters = left margin
107-108Tab interval
109CR display0 = soft, non-zero = hard
110Auto-justify on copy/move0 = no, non-zero = yes
111-126Associated application name
127-143Reserved Application Area

STRING

Record TypeCodeBody length
STRING51(33h)variable

Record Description: Value of string formula

Used in Symphony only.

Byte NumberByte Description
0format (see Appendix A, Cell Format Encoding)
1-2column
3-4row
5+NULL terminated ASCII string

PASSWORD

Record TypeCodeBody length
PASSWORD55(37h)4 byte

Record Description: File lockout (CHKSUM)

This is proprietary information.

Used in Symphony only.

Byte NumberByte Description
-- not available --

LOCKED

Record TypeCodeBody length
LOCKED56(38h)1 byte

Record Description: Lock Flag

Used in Symphony only.

Byte NumberByte Description
00 = OFF
1 = ON

QUERY

Record TypeCodeBody length
QUERY60(Ch)127 bytes

Record Description: Query settings

Used in Symphony only.

Table 5 Query Record Structure

Byte NumberByte Description
0-15NameNULL terminated ASCII string
16-17Input rangestarting column
18-19starting row
20-21ending column
22-23ending row
24-25Output Rangestarting column
26-27starting row
28-29ending column
30-31ending row
32-33Criteria Rangestarting column
34-35starting row
36-37ending column
38-39ending row
40-41Form Entrystarting column
42-43starting row
44-45ending column
46-47ending row
48-49Form Def. Rangestarting column
50-51starting row
52-53ending column
54-55ending row
56-57Report Outputstarting column
58-59starting row
60-61ending column
62-63ending row
64-65Report Headerstarting column
66-67starting row
68-69ending column
70-71ending row
72-73Report Footerstarting column
74-75starting row
76-77ending column
78-79ending row
80-81Table Rangestarting column
82-83starting row
84-85ending column
86-87ending row
88-89Input Cellstarting column
90-91starting row
92-93ending column
94-95ending row
96-971st Key rangestarting column
98-99starting row
100-101ending column
102-103ending row
104-1052nd Key rangestarting column
106-107starting row
108-109ending column
110-111ending row
112-1133rd Key rangestarting column
114-115starting row
116-117ending column
118-119ending row
120Last command0 = no command, 1 = find, 2 = extract, 3 = delete, 4 = unique
1211st Key order0 = descending order, FF = ascending order
1222nd Key order0 = descending order, FF = ascending order
1233rd Key order0 = descending order, FF = ascending order
124Report number of records0 = multiple, FF = single
125Number of records0 = multiple, FF = single
126Marks0 = yes, FF = no

QUERYNAME

Record TypeCodeBody length
QUERYNAME61(3Dh)16 bytes

Record Description: Current Query Name

Used in Symphony only.

Byte NumberByte Description
0-15NULL terminated ASCII string

PRINT

Record TypeCodeBody length
PRINT62(3Eh)679 bytes

Record Description: Print record

Used in Symphony only.

Table 6 Print Record Structure

Byte NumberByte Description
0-15Print setting nameNULL terminated ASCII string
16-17Source rangestarting column
18-19starting row
20-21ending column
22-23ending row
24-25Row borderstarting column
26-27starting row
28-29ending column
30-31ending row
32-33Column borderstarting column
34-35starting row
36-37ending column
38-39ending row
40-41Destinationstarting column
42-43starting row
44-45ending column
46-47ending row
48Print format0 = as displayed, non-zero = formulas
49Page breaks0 = yes, non-zero = no
50Line spacing
51-52Left Margin
53-54Right Margin
55-56Page length
57-58Top
59-60Bottom of page
61-101Setup stringNULL terminated ASCII string
102-342HeaderNULL terminated ASCII string
343-584FooterNULL terminated ASCII string
585-600Source database nameNULL terminated ASCII string
601Attribute0 = no, non-zero = yes
602Space compression0 = no, non-zero = yes
603Print destination0 = printer, 1 = file, 2 = range
604-605Starting page
606-607Ending page
608-677Destination filenameNULL terminated ASCII string
678Wait0 = no, non-zero = yes

PRINTNAME

Record TypeCodeBody length
PRINTNAME63(3Fh)16 bytes

Record Description: Current Print Record Name

Used in Symphony only.

Byte NumberByte Description
0-15NULL terminated ASCII string

GRAPH2

Record TypeCodeBody length
GRAPH264(40h)499 bytes

Record Description: Graph record

Used in Symphony only.

Table 7 Symphony Graph Record Structure

Byte NumberByte Description
0-15NameNULL terminated ASCII string
16-17X Rangestarting column
18-19starting row
20-21ending column
22-23ending row
24-25A Rangestarting column
26-27starting row
28-29ending column
30-31ending row
32-33B Rangestarting column
34-35starting row
36-37ending column
38-39ending row
40-41C Rangestarting column
42-43starting row
44-45ending column
46-47ending row
48-49D Rangestarting column
50-51starting row
52-53ending column
54-55ending row
56-57E Rangestarting column
58-59starting row
60-61ending column
62-63ending row
64-65F Rangestating column
66-67starting row
68-69ending column
70-71ending row
72-73A Labelsstarting column
74-75starting row
76-77ending column
78-79ending row
80-81B Labelsstarting column
82-83starting row
84-85ending column
86-87ending row
88-89C Labelsstarting column
90-91starting row
92-93ending column
94-95ending row
96-97D Labelsstarting column
98-99starting row
100-101ending column
102-103ending row
104-105E Labelsstarting column
106-107starting row
108-109ending column
110-111ending row
112-113F Labelsstarting column
114-115starting row
116-117ending column
118-119ending row
120Graph type0 = XY, 1 = bar, 2 = pie, 4 = line, 5 = stacked bar
121Grid0 = none, 1 = horizontal, 2 = vertical, 3 = both
122Color0 = black-white, FF = color
123A Range line format0 = none, l = line, 2 = symbol, 3 = line-symbol
124B Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
125C Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
126D Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
127E Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
128F Range line format0 = none, 1 = line, 2 = symbol, 3 = line-symbol
129A Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
130B Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
131C Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
132D Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
133E Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
134F Range data label alignment0 = center, 1 = right, 2 = below, 3 = left, 4 = above
135X scale0 = auto FF = manual
136-143X lower limit in floating point format
144-151X upper limit in floating point format
152Y scale0 = automatic FF = manual
153-160Y lower limit in floating point format
161-168Y upper limit in floating point format
209-224First title
225-248Second title
249-288X title
289-328Y title
329-348A legend
349-368B legend
369-388C legend
389-408D legend
409-428E legend
429-448F legend
449X format
450Y format
451-452Skip factor
453X scale flag (x1K)0 = ON, FF = OFF
454Y scale flag(x1K)0 = ON, FF = OFF
455suppress0 = no, else = yes
456-463Bar origin (float)
464-471X linear scale (float)
472-479Y linear scale (float)
480X log scale
481Y log scale
482graph region colorX hue code
483A hue code
484B hue code
485C hue code
487D hue code
488F hue code
489-490Y width
491-498Aspect (float)

GRAPHNAME

Record TypeCodeBody length
GRAPHNAME65 (41h)16 bytes

Record Description: Current Graph Record Name

Used in Symphony only.

Byte NumberByte Description
0-15NULL terminated ASCII string

ZOOM

Record TypeCodeBody length
ZOOM66 (42h)9 bytes

Record Description: Original coordinates expanded window

Used in Symphony only.

Byte NumberByte Description
0iszoom?   0 = no, 1 = yes
1-2X coordinates
3-4Y coordinates
5-6column depth
7-8row depth

SYMSPLIT

Record TypeCodeBody length
SYMSPLIT67 (43h)2 bytes

Record Description: Number of split windows

Used in Symphony only.

Byte NumberByte Description
0-1number of split windows

NSROWS

Record TypeCodeBody length
NSROWS68 (44h)2 bytes

Record Description: Number of screen rows

Used in Symphony only.

Byte NumberByte Description
0-1number of screen rows

NSCOLS

Record TypeCodeBody length
NSCOLS69 (45h)2 bytes

Record Description: Number of screen columns

Used in Symphony only.

Byte NumberByte Description
0-1Number of screen columns

RULER

Record TypeCodeBody length
RULER70 (46h)25 bytes

Record Description: Name ruler range

Used in Symphony only.

Byte NumberByte Description
0-15NameNULL terminated ASCII string
16-17Rangestarting column
18-19starting row
20-21ending column
22-23ending row
24Range type0 = single cell, 1 = range

NNAME

Record TypeCodeBody length
NNAME71 (47h)25 bytes

Record Description: Named sheet range

Used in Symphony only.

Byte NumberByte Description
0-15NameNULL terminated ASCII string
16-17Rangestarting column
18-19starting row
20-21ending column
22-23ending row
24Range type0 = single cell, 1 = range

ACCOM

Record TypeCodeBody length
ACOMM72 (48h)65 bytes

Record Description: Autoload communications file

Used in Symphony only.

Byte NumberByte Description
0-64Path name to Autoload file: NULL terminated ASCII string

AMACRO

Record TypeCodeBody length
AMACRO73 (49h)8 bytes

Record Description: Autoexecute macro address

Used in Symphony only.

Byte NumberByte Description
0-1starting column
2-3starting row
4-5ending column
6-7ending row

PARSE

Record TypeCodeBody length
PARSE74 (4Ah)16 bytes

Record Description: Query parse information

Used in Symphony only.

Byte NumberByte Description
0-1Parse rangestarting column
2-3starting row
4-5ending column
6-7ending row
8-9Review rangestarting column
10-11starting row
12-13ending column
14-15ending row


APPENDIX A: Cell Format Encoding

The first byte of a content-related record contains a cell format code.

Format is determined at the bit level.

Table 8 Cell Format Encoding

 Bit number     Description               Code             Meaning
 7              protection                1                protected
                                          0                unprotected

 4,5,6          format type               0                fixed
                                          1                scientific notation
                                          2                currency
                                          3                percent
                                          4                comma
                                          5                unused
                                          6                unused
                                          7                special
 0,1,2,3        number of decimal         0-15
                 places decoded
                 (if format type = 0-6)

                special format type       0                +/-
                (if format type = 7)      1                general
                                          2                day-month-year
                                          3                day-month
                                          4                month-year
                                          5                text
                (Symphony only)           6                hidden
                (Symphony only)           7                date;hour-min-sec
                (Symphony only)           8                date;hour-min
                (Symphony only)           9                date;intnt'l1
                (Symphony only)           10               date;intnt'l1
                (Symphony only)           11               time;intnt'l1
                (Symphony only)           12               time;intnt'l2
                                          13-14            unused
                                          15               default

 EXAMPLE

 Currency format, two decimal places, unprotected cell

 Bit Number    7   6   5   4   3   2   1   0
 Binary Code   0   0   1   0   0   0   1   0
                   ---------
                  Format Type ---------------
               Protection     Number of Decimal Places
                                  or Special Format

 The byte number is 0.
 The hex code is 22.

 Example

 Special format, month-year, protected cell

 Bit Number     7   6   5   4   3   2   1   0
 Binary Code    1   1   1   1   0   1   0   0
                    ---------
                   Format Type  -------------
                 Protection    Number of Decimal Places
                                  or Special Format

 The byte number is 0.
 The hex code is F4.

APPENDIX B: The Formula Compiler

This appendix describes the internal workings of the formula compiler. The compiler transforms an ASCII string of characters representing a formula to its Reverse Polish code. The basic algorithm utilizes and SR parser (SR = shift and reduce). The aim of the parser is to apply a set of reduction rules which embody the syntax of the compiler to an input string. Formula code is compiled to a temporary buffer.

Lexicon Analysis

A lexical analyzer breaks up the input string into lexical units called tokens. A token is a substring of the original input string operand, operator, or special symbol (such as comma, parentheses, etc.) In addition, the lexical analyser supplies two special tokens, "beginning of formula" (boform) and "end of formula" (eoform), to facilitate the compilation process. The lexical analyzer identifies and processes literals (both number and string), cell and range references, operators, and function calls. It assigns a unique code to each distinct operator, function, or type of operand.

A function with no arguments is treated like a number.

Syntax Analysis

The syntactical analysis of a formula is accomplished by processing a list of tokens in left-to-right order. A stack called the syntax is also used during the syntactical scan. The basic algorithm is as follows:

Repeat the following steps:

1) Get the next token

2) If the token is a literal or cell reference:
a) Push the number code on the syntax stack
b) Push the number code on the syntax stack

3) If the token is a range reference:
a) Compile code to push the range reference
b) Push the range code on the syntax stack

4) Otherwise push the token code for the token on the syntax stack.

For each syntax rule, if the pattern on the top of the syntax matches the rule pattern take the action associated with the rule and start scanning from the beginning for any additional rules which may apply.

When a token code is pushed on the syntax stack, an additional word of zeros is also pushed on the stack. This is used when compiling function calls to hold the function's argument count.

Rule Matching

A relatively small number of rules are used to process formulas of arbitrary complexity. If a rule matches the top of the syntax stack, then the compiler takes a specific action and rule scanning starts again with the first rule. Each rule matches certain patterns on the syntax stack. A typical rule might be: if the top of the stack is the token for right parenthesis, and the next-to-top is a number, and the second form the top is a left parenthesis, then pop the top three items from the syntax stack and push the number on the syntax stack.

This rule can be more succinctly represented as:

                        Stack

          Before                      After                 Action
          )
          number
          (                           number                none
The Rules

The following are the syntax rules used to process formulas. Note that the order of the rules is important. The rules for compilation of operators used additional tables which assign a precedence number and opcode to each legal unary and binary operator. Thus, for example, there is a single token code for minus sign (-), but there are two opcodes one for unary minus and one for binary minus. In addition, these two operators, while lexically identical, also have different precedence. In general, operators of higher precedence will be performed before operators of lower precedence are performed left-to-right. All special operators (boform, eoform, parentheses, comma, etc.) are implicitly assigned a precedence of zero.

Rule 1 Termination test

                  Stack

         Before           After       Action
         eoform                       Output a return code to compile buffer
         number                       Return, indicating successful compile
         boform

 Rule 2  Function argument processing

                 Stack
         Before          After       Action
         '                           Error if range argument illegal for
         number or range             function.
         (               (           Increment argument count on stack
         function        function

 Rule 3  Process final function argument

                 Stack
         Before         After        Action
         )                           Error if range argument illegal for
         number or range             function.
         (                           Increment argument count on stack
         function       number       Compile function opcode
                                     If list function, compile argument
                                     count; otherwise error is wrong
                                     argument count.

 Rule 4  Parenthesis removal

                Stack
        Before         After        Action
        )                           Compile parenthesis opcode
        number
        (              number
        operator       operator

 Rule 5  Binary operators

               Stack
        Before         After        Action
        op2                         If binary op<binary op, rule does
        number                      not match.  Otherwise, compile opcode
        op1            op2          for operator op1.

 Rule 6  Unary operators

               Stack
        Before      After           Action
        op2                         I unary op<binary op, rule does
        number      op2             not match.  Otherwise, compile opcode.
        op1         number          for operator op 1.

 Rule 7  Error detection

              Stack
       Before       After          Action
       eoform                      Return indicating unsuccessful compile

Table 9 Operator Precedence Table

OperatorUnary PrecedenceBinary Precedence
+64
-64
*na5
/na7
^na3
=na3
< >na3
< =na3
> =na3
<na3
>na3
#and#na1
#or#na1
#not#2na

Example:

Using the above rules, we can now see how a particular formula is compiled. Let us consider the following formula:

                  3+5*6

 This is broken up by the lexical analyzer into seven tokens.

                  boform
                  3
                  +
                  5
                  *
                  6
                  eoform

 The syntax scans proceed as follows until a matching rule is found:

 Stack

 boform           number         +            number
                  boform         number       +
                                 boform       number
                                              boform

 Compile buffer

                  push 3         push 3       push 3
                                              push 5


 At this point, rule 5 is invoked, but since the precedence of boform is
 zero, no action is taken.

 Stack

 *                number
 number           *
 +                number
 number           +
 boform           number
                  boform

 Compile buffer

 push 3           push 3
 push 5           push 5
                  push 6
At this point, since the binary precedence of + is lower than the binary precedence of *, rule 5 does apply, and the opcode for * is compiled. The stack is reduced by replacing number * number by number and scan is made, but no further rule applies.
 Stack

 number          eoform
 +               number
 number          +
 boform          number
                 boform

 Compile buffer

 push 3          push 3
 push 5          push 5
 push 6          push 6

Rule 5 applies again, and the opcode for + is compiled, reducing the stack to boform, number, eoform. Rescanning finds a match on rule 1 which compiles a return opcode and terminates. The final compiled code is thus:

 push 3
 push 5
 push 6
 *
 +
 return

A Note on the Decompiler

The algorithm for the formula decompiler was taken verbatim from:

Writing Interactive Compilers and Interpreters, P.J. Brown, John Wiley and Sons, 1979. See chapter 6.2. The algorithm itself is described on pages 216 and 217.

This algorithm is also described in the following article.

More on the Re-creation of Source Code from Reverse Polish, P.J. Brown, Software Practice and Experience, Vol 7, 545-551 (1977).

WORKSHEET COLUMN DESIGNATORS

Most records within the 1-2-3 Condensed Worksheet format are specified with column/row designators (for example, column 0, row 0 equals A1). When determining the column designator, the table below will help make conversion easier.

ColumnHexDecColumnHexDecColumnHexDec
A00BA3452DA68104
B11BB3553DB69105
C22BC3654DC6A106
D33BD3755DD6B107
E44BE3856DE6C108
F55BF3957DF6D109
G66BG3A58DG6E110
H77BH3B59DH6F111
I88BI3C60DI70112
J99BJ3D61DJ71113
KA10BK3E62DK72114
LB11BL3F63DL73115
MC12BM4064DM74116
ND13BN4165DN75117
OE14BO4266DO76118
PF15BP4367DP77119
Q1016BQ4468DQ78120
R1117BR4569DR79121
S1218BS4670DS7A122
T1319BT4771DT7B123
U1420BU4872DU7C124
V1521BV4973DV7D125
W1622BW4A74DW7E126
X1723BX4B75DX7F127
Y1824BY4C76DY80128
Z1925BZ4D77DZ81129
AA1A26CA4E78EA82130
AB1B27CB4F79EB83131
AC1C28CC5080EC84132
AD1D29CD5181ED85133
AE1E30CE5282EE86134
AF1F31CF5383EF87135
AG2032CG5484EG88136
AH2133CH5585EH89137
AI2234CI5686EI8A138
AJ2335CJ5787EJ8B139
AK2436CK5888EK8C140
AL2537CL5989EL8D141
AM2638CM5A90EM8E142
AN2739CN5B91EN8F143
AO2840CO5C92EO90144
AP2941CP5D93EP91145
AQ2A42CQ5E94EQ92146
AR2B43CR5F95ER93147
AS2C44CS6096ES94148
AT2D45CT6197ET95149
AU2E46CU6298EU96150
AV2F47CV6399EV97151
AW3048CW64100EW98152
AX3149CX65101EX99153
AY3250CY66102EY9A154
AZ3351CZ67103EZ9B155

ColumnHexDecColumnHexDec
FA9C156HADO208
FB9D157HBD1209
FC9E158HCD2210
FD9F159HDD3211
FEAO160HED4212
FFA1161HFD5213
FGA2162HGD6214
FHA3163HHD7215
FIA4164HID8216
FJA5165HJD9217
FKA6166HKDA218
FLA7167HLDB219
FMA8168HMDC220
FNA9169HNDD221
FOAA170HODE222
FPAB171HPDF223
FQAC172HQEO224
FRAD173HRE1225
FSAE174HSE2226
FTAF175HTE3227
FUBO176HUE4228
FVB1177HVE5229
FWB2178HWE6230
FXB3179HXE7231
FYB4180HYE8232
FZB5181HZE9233
GAB6182IAEA234
GBB7183IBEB235
GCB8184ICEC236
GDB9185IDED237
GEBA186IEEE238
GFBB187IFEF239
GGBC188IGFO240
GHBD189IHF1241
GIBE190IIF2242
GJBF191IJF3243
GKCO192IKF4244
GLC1193ILF5245
GMC2195IMF6246
GNC3195INF7247
GOC4196IOF8248
GPC5197IPF9249
GQC6198IQFA250
GRC7199IRFB251
GSC8200ISFC252
GTC9201ITFD253
GUCA202IUFE254
GVCB203IVFF255
GWCC204
GXCD205
GYCE206
GZCF207

ANALYSIS OF 1-2-3 WORKSHEET FILE

The worksheet shown below was created in 1-2-3 and saved to disk.

                                    Key:

                                    A2..A5 Named Range (code 11)
          EXAMPLE                       A2: Label (code 15)
             100                        A3: Integer (code 13)
            12.5                        A4: Number (code 14)
            87.5                        A5: Formula (+A3-A4)
                                            (code 16)

The example shown below is a partial hex dump of this worksheet file. By reading each record header, you can determine the type of record you are encountering. The record header will also tell you the length of that follows the header. By analyzing the record header, you can read the records you want and skip unrelated records.

    362B:0100                           06 00 08 00 00 00 00 00 00 00
    362B:0110        04 00 2F 00 01 00  01 02 00 01 00 FF 03 00 01 00
    362B:0120        00 04 00 01 00 00  05 00 01 00 FF 07 00 1F 00 00
    362B:0130        00 01 00 71 00 09  00 08 00 14 00 00 00 00 00 00
    362B:0140        00 00 00 00 00 00  00 04 00 04 00 48 00 00 0B 00
    362B:0150        18 00 54 45 53 54  00 00 00 00 00 00 00 00 00 00
    362B:0160        00 00 00 00 01 00  00 00 04 00 18 00 19 00 00 FF
    362B:0170        FF 00 00 FF FF 00  00 FF FF 00 00 FF FF 00 00 FF
    362B:0180

    362B:05C0
    362B:05D0        00 00 00 00 00 00  00 00 00 00 00 00 00 00 00 00
    362B:05E0        00 00 00 00 00 00  00 00 00 00 00 00 00 00 00 00
    362B:05F0        00 00 00 00 71 71  01 00 0F 00 0E 00 FF 00 00 01
    362B:0600        00 27 45 58 41 4D  50 4C 45 00 0D 00 07 00 FF 00
    362B:0610        00 02 00 64 00
    362B:0620                           10 00 1B 00 FF 00 00 04 00 00
    362B:0630        00 00 00 00 E0 55  40 0C 00 01 00 80 FE BF 01 00
    362B:0640        80 FF BF 0A 03

ADDENDUM to WORKSHEET FILE FORMAT Document (2-19-85):

The following supplements the discussion of the FORMULA record type in the Worksheet File Format document.

Formula Record Type

Byte NumberByte Description
0format
1-2column
3-4row
5-12formula numeric value (IEEE long real)
13-14formula size (bytes)
15+formula code, compiled Reverse-Polish internal notation; max of 2048 bytes

OpcodeExplanation
0push constant...followed by 8 byte #
1push variable...followed by 4 byte column,row...a relative coordinate has its most significant bit set
2push range...followed by 8 byte begin/end column,row
3end of formula
4parentheses
5integer constant...followed by 2 byte integer
6push string...followed by null terminated string
7unused
8unary -
9binary +
10binary -
11*
12/
13^
14=
15<>
16<=
17>=
18<
19>
20#AND#
21#OR#
22#NOT#
23unary
24&
25..30unused
31@na
32@err
33@abs
34@int
35@sqrt
36@log
37@ln
38@pi
39@sin
40@cos
41@tan
42@atan2
43@atan
44@asin
45@acos
46@exp
47@mod
48@sel
49@isna
50@iserr
51@false
52@true
53@rand
54@date
55@now
56@pmt
57@pv
58@fv
59@if
60@day
61@month
62@year
63@round
64@time
65@hour
66@minute
67@second
68@isnumber
69@isstring
70@length
71@value
72@fixed
73@mid
74@chr
75@ascii
76@find
77@datevalue
78@timevalue
79@cell pointer
80@sum..followed by 1 byte >>> # of args
81@avg..followed by 1 byte >>> # of args
82@cnt..followed by 1 byte >>> # of args
83@min..followed by 1 byte >>> # of args
84@max..followed by 1 byte >>> # of args
85@vlookup
86@npv
87@var
88@std
89@irr
90@hlookup
91@dsum
92@davg
93@dcnt
94@dmin
95@dmax
96@dvar
97@dstd
98@index
99@cols
100@rows
101@repeat
102@upper
103@lower
104@left
105@right
106@replace
107@proper
108@cell
109@trim
110@clean
111@s
112@v
113@streq
114@call
115@indirect


Format © 2002 by Tim Colgate

You may redistribute this document freely provided you retain both the original Lotus copyright message and the © Tim Colgate above. No responsibility can be accepted for any errors or omissions in this document. Please send corrections and suggestions to me.