def WriteTableHeaderRow(Writer, ValidMols):
    """Write out table header row."""

    if not OptionsInfo["TableHeader"]:
        return
    
    TableHeaderStyle = OptionsInfo["TableHeaderStyle"]
    if TableHeaderStyle is None:
        Writer.write("""      <thead>\n""")
        Writer.write("""        <tr>\n""")
    elif re.match("^(thead|table)", TableHeaderStyle):
        Writer.write("""      <thead class="%s">\n""" % TableHeaderStyle)
        Writer.write("""        <tr>\n""")
    else:
        Writer.write("""      <thead>\n""")
        Writer.write("""        <tr bgcolor="%s"\n""" % TableHeaderStyle)

    if OptionsInfo["CounterCol"]:
        Writer.write("""          <th></th>\n""")
    
    # Write out rest of the column headers...
    MolCount = len(ValidMols)
    ColCount = GetColCount(MolCount)
    for ColIndex in range(0, ColCount):
        ColLabel = MiscUtil.GetExcelStyleColumnLabel(ColIndex + 1)
        Writer.write("""          <th>%s</th>\n""" % ColLabel)
        
    Writer.write("""        </tr>\n""")
    Writer.write("""      </thead>\n""")
def WriteTableFooterRow(Writer, ValidMols):
    """Write out table footer row."""

    if not OptionsInfo["TableFooter"]:
        return
    
    Writer.write("""      <tfoot>\n""")
    Writer.write("""        <tr>\n""")

    if OptionsInfo["CounterCol"]:
        Writer.write("""          <td></td>\n""")

    # Write out rest of the column headers...
    MolCount = len(ValidMols)
    ColCount = GetColCount(MolCount)
    for ColIndex in range(0, ColCount):
        ColLabel = MiscUtil.GetExcelStyleColumnLabel(ColIndex + 1)
        Writer.write("""          <td>%s</td>\n""" % ColLabel)
        
    Writer.write("""        </tr>\n""")
    Writer.write("""      </tfoot>\n""")