Changing the Look of Things
Now that we have learned to build tables with the class, let us take a look at how to spice them up a bit. To do this we have a wide selection of tools which allow us to change the way that the table looks on 3 levels:
- Table Level
- Row or Column Level
- Cell Level
1. At the table level we manipulate properties with either the setAllAttibutes or the updateAllAttributes functions. The only difference between these two functions is that updateAllAttributes will add attributes to your table, leaving current attributes in place while setAllAttributes will replace whatever has been previously set. The usage of these two functions is as follows:
<?php
setAllAttributes($properties);
updateAllAttributes($properties);
?>
Where $properties is either a string or an associative array as discussed previously.
2. To manipulate the attributes of rows and columns we use the following functions:
<?php
setRowAttributes($row, $attributes);
updateRowAttributes($row, $attributes, $inTR);
setColAttributes($col, $attributes);
updateColAttributes($col, $attributes);
?>
The use of these functions is fairly straight forward but there is one important thing to remember. First the $row and $col attributes are the numbers of the row or column that you wish to change. Numbering of rows and columns starts at 0, so in order to make the first row of the table have a background color of blue, you would use the following code segment:
<?php
$attributes = array(bgcolor=>#0000FF);
$table->updateRowAttributes(0, $attributes);
?>
3. In order to set attributes of individual cells we would use one of these two functions:
<?php
setCellAttributes($row, $col, $attributes);
updateCellAttributes($row, $col, $attributes);
?>
Both functions are very straight forward, simply specify the cell location by row and column number then specify the attributes. Again, row and column numbers start at 0.