Different from other spreadsheet applications, esCalc spreadsheet isn’t designed for holding a normal two-dimensional table, but for holding data in a hierarchical way. Here you’ll see in what type of structure the data is stored in esCalc and the hierarchical relationships between rows.
1 .Row number, slave row number and level
A simple state population table will be used to illustrate the basic structure of data in esCalc:
In this table, below the head row there is the detailed data of some states’ population in 2010, with total population summarized at the end.
The hierarchy section, outlined in red above, lies on the left-most side of an esCalc cellset. Next to it are head cells of the rows, outlined in blue, which contain the row numbers for showing the rows’ vertical positions in the table.
This esCalc table has a hierarchical structure. The first row and the fifth row contain the general data, such as headers, summarized data, and they are each unique across the cellset. The second, third and fourth row contain detailed data about states. These rows holding data of a specific state each are similar.
In an esCalc cellset, you read a row’s level in the hierarchy section. The column numbers at the top of the hierarchy section are the level numbers. Every row in the cellset has a number in its corresponding level. This in esCalc is called the slave row number, whose corresponding level number represents the level where the row is in. The slave row number of the first row, for example, is 1, and its corresponding column number is 0. That is to say, the first row is in level 0, or you can call it level 0 row. For the same reason, the fifth row is also a level 0 row though its slave row number is 2. And the second, third and fourth row – all of them are rows of level 1 with slave row numbers being 1.
Often the tables you handle are more complicated. To add city population data to each state data, for example:
There are three hierarchical levels in this table. Level 0 includes the first and the twelfth row; level 1 includes the second, the fifth and the eighth row; and level 2 includes rows whose numbers are 3,4,6,7,9,10,11. You can see that level 0 is about the general data, level 1 covers state population data and level 2 covers city population data. Different from rows in the other two levels, the first and the twelfth row of level 0 obviously convey different kinds of information though both are summaries. This find expression in their slave row numbers in the hierarchy section. The meaning of slave row numbers will be discussed in the next section.
2. Band, master row and slave row
Here is an even more complicated table, where the number of cities under each state is counted:
First let’s study the macrostructure of the table. It comprises the header row, the grand total row and population data of every state. The population data of each state consists of the state’s population, population in some of the state’s cities and the subtotal. At last, each city’s population data only covers one row.
As can be seen, a state’s population data includes not only the state’s population and the subtotal that belong to level 1, but the population data of the cities in the state. Illinois data, for example, covers the city population data in the seventh and eighth row, besides the sixth and ninth row. This means Illinois data is made up of consecutive rows from the sixth row to the ninth row. And this stretch of rows is known as a band. Similar to the hierarchy of a cellset table, a band has its own hierarchical levels. The band of Illinois data belongs to the state level, or level 1. The whole table is a band of level 0 and the eighth row is a Chicago city’s band of level 2 in itself.
In an esCalc table, the slave row number of the first row in each band is 1, and this row whose slave row number is 1 is the band’s master row, whose level is the one where the band is in. In a band of level k, there is only one master row of level k; if there are other rows of the same level, their slave row numbers will be arranged in sequence. All the rows of level k in a level k band are called slave rows. The master row is considered a special slave row. Therefore the slave row number is the serial number of a slave row in a band of level k. In the California band, for example, the rows of level 1 are the tenth and the fourteenth row, whose slave row numbers are 1 and 2 respectively. In this case, the tenth row is the band’s master row, but both it and the fourteenth row are the slave rows.
In esCalc, you can locate a band according to slave row numbers in the hierarchy section. A band is a stretch of rows that start from a master row of level k and extend until another master row of the same level, or any row of a higher level, appears. For example, the tenth row is in level 1 and its slave row number is 1, so it is a master row of level 1. From this row you search downward until you find another master row of level 1, or any row of level 0. Then you find the fifteenth row is a row of level 0, so you know the band of the state of California is from the tenth row to the fourteenth row.
esCalc requires every band to start with a master row of the same level as the one to which the band belongs. If a band really starts with a row with relatively lower level, you need to add an empty master row before it. That is the case where the state data is put at the end of the band:
By doing so, the band of the state of California is from the twelfth row, which is the master row, to the seventeenth row. 2 and 3 are respectively the slave row numbers of the sixteenth and the seventeenth row. You can right-click on the first cell of the twelfth row and select Hide to hide all empty rows, as shown below:
This will not affect the display of the row numbers and slave row numbers of other rows. To restore the display of the hidden rows, you need to select the rows between which the hidden row is sandwiched, such as the first and the third row, and select Show on the context menu. Details about the operation of hiding rows will be covered in esCalc Editing: The Band.
3. Parent row, sub-row and descendant row
In esCalc, the master row and slave row are used to represent the relationship between rows of the same level. On another hand, the parent row and sub-row represents the relationship between rows of different levels. In a table, the row of level k-1 immediately above the rows of level k is their parent row. Obviously a row of level 0 does not have a parent row, but every row of other levels has one. Similarly the neighboring rows of level k+1 below the row of level k are all the latter’s sub-rows. Under level k, its descendant rows include all consecutive rows of level lower than k. The rows in esCalc spreadsheet do not necessarily have their sub-rows or descendant rows, but they, except for the rows of level 0, definitely have their parent rows.
Below is the city population table:
Different from the preceding tables, this one only stores the city population data. Each block of detailed city data is headed by a header row – a slave row. From this table you’ll know more clearly about the parent row, sub-row and descendant row.
Look at the eighth row, which is a level 1 row. Its sub-rows are the neighboring two level 2 rows below – the ninth and tenth row. Their parent row is the eighth row. Here the “neighboring rows” refer to those below that are not the same level or higher level.
Equally, the sub-rows of the thirteenth row are rows from the fourteenth to sixteenth row, and therefore, the latter’s parent row is the thirteenth row. The first row is the level-0 row whose sub-rows are level-1 rows below, whose row numbers are 2,3,6,7,8,11,12,13,17; and all these rows’ parent row is the first row. So you can see the parent row and the sub-row are a set of mutually opposite concepts. In this table, rows whose numbers are 2,3,6,7,8,11,12,13,17 do not have their sub-rows. And because there are three hierarchical levels – 0, 1, 2, all rows of level 2 do not have sub-rows.
In esCalc, a row’s descendant rows include not merely all its sub-rows, but all descendant rows of these sub-rows. In above table, the sub-rows of rows of level 1 are also their descendant rows. But that is not the case for level-0 rows. The first row’s descendent rows cover all the 16 rows from the second row through to the last one. A row that does not have any sub-row possesses no descendant rows.