<!-- chapterName "Lesson 9: Table Styles - pt. 2: styling blocks of cells" -->

<codesnippet language="xml" style="code" ><![CDATA[
<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="example_09.pdf">

    <template showBoundary="1">
        <pageTemplate id="main">

            <pageGraphics>
                
            </pageGraphics>

            <frame id="first" x1="200" y1="400" width="150" height="200"/>

        </pageTemplate>

    </template>

    <stylesheet>
        <blockTableStyle id="blocktablestyle3">
            <!-- This sets a font for the second row -->
            <blockFont name="Helvetica-BoldOblique" size="16" start="0,1" stop="2,1"/>
            
            <!-- This sets a textColor for all the text in the table ...-->
            <blockTextColor colorName="purple"/>
            <!-- ...and this overrides it for the second column -->
            <!-- using -1 to refer to the last item.            -->
            <blockTextColor colorName="black" start="1,0" stop="1,-1"/>
            <!-- Use of linestyles for left, right, top and bottom gridlines -->
            <lineStyle kind="LINEBELOW" colorName="red" start="0,3" stop="-1,3" thickness="2"/>
            <lineStyle kind="LINEAFTER" colorName="maroon" start="0,3" stop="-1,3" thickness="2"/>
            <lineStyle kind="LINEBEFORE" colorName="black" start="0,3" stop="-1,3" thickness="2"/>
            <lineStyle kind="LINEABOVE" colorName="yellow" start="0,3" stop="-1,3" thickness="2"/>
            <!-- Use of grid lineStyle, for 'all in one' formatting-->
            <lineStyle kind="GRID" colorName="green" thickness="1" start="0,0" stop="-1,0" />
        </blockTableStyle>
    </stylesheet>

    <story> 
        
        <blockTable style="blocktablestyle3">
            <tr>
                <td>This is </td>
                <td>a table with</td>
                <td>three columns</td>
            </tr>
            <tr>
                <td>demonstrating how</td>
                <td>to style each cell</td>
                <td>differently.</td>
            </tr>
            <tr>
                <td>Have a look </td>
                <td>at blocktablestyle3 </td>
                <td>to see how it works.</td>
            </tr>
            <tr>
                <td>Use line styles for different</td>
                <td>table borders; note that </td>
                <td>padding is on by default.</td>
            </tr>
        </blockTable>

    </story>
</document>

]]></codesnippet>

<para>This example demonstrates the use of start and stop values in the &lt;blockTableStyle&gt; element tags.  These can be used to specify particular 'blocks' of rows or columns to which you want to apply a style.</para>

<para>The 'start' and 'stop' tags are used to describe the beginning and end of 'blocks' of cells within the table, where the style should be applied, using an (column,row) notation with the numbering starting from zero. So, for example, the top left-hand cell is referred to as (0,0), and (2,1) refers to the third column on the second row.  Negative numbers can also be used to count cells backwards from the end of the last cell, so (-1,-1) always refers to the bottom right hand cell, and e.g. (-1,1) refers to the last column on the second row.</para>

<blockTable style="simpleStyle">
    <tr>
        <td>(0,0)</td>
        <td>(1,0)</td>
        <td>(2,0)</td>
    </tr>
    <tr>
        <td>(0,1)</td>
        <td>(1,1)</td>
        <td>(2,1)</td>
    </tr>
    <tr>
        <td>(0,2)</td>
        <td>(1,2)</td>
        <td>(2,2)</td>
    </tr>
</blockTable>


<para spaceBefore="10">So, to apply a style to the second row of the above table, you would specify start="0,1" stop="2,1".</para>

<para>Another important point to note about tables is that cell padding is on by default.  You have to explicitly set it to zero using blockTableStyles -otherwise, it is set to 5 points in all directions.  This can be a source of confusion when using the start/stop notation, because if you set padding for a particular range of cells, it will revert to the default values outside of that range - not go to zero as you might expect.</para>

<para>This example also shows how to apply styles to the gridlines, using lineStyles.</para>
