def ToHtml(self, columns_order=None, order_by=()):
table_template = "<STR_LIT>"<EOL>columns_template = "<STR_LIT>"<EOL>rows_template = "<STR_LIT>"<EOL>row_template = "<STR_LIT>"<EOL>header_cell_template = "<STR_LIT>"<EOL>cell_template = "<STR_LIT>"<EOL>if columns_order is None:<EOL><INDENT>columns_order = [col["<STR_LIT:id>"] for col in self.__columns]<EOL><DEDENT>col_dict = dict([(col["<STR_LIT:id>"], col) for col in self.__columns])<EOL>columns_list = []<EOL>for col in columns_order:<EOL><INDENT>columns_list.append(header_cell_template %<EOL>html.escape(col_dict[col]["<STR_LIT:label>"]))<EOL><DEDENT>columns_html = columns_template % "<STR_LIT>".join(columns_list)<EOL>rows_list = []<EOL>for row, unused_cp in self._PreparedData(order_by):<EOL><INDENT>cells_list = []<EOL>for col in columns_order:<EOL><INDENT>value = "<STR_LIT>"<EOL>if col in row and row[col] is not None:<EOL><INDENT>value = self.CoerceValue(row[col], col_dict[col]["<STR_LIT:type>"])<EOL><DEDENT>if isinstance(value, tuple):<EOL><INDENT>cells_list.append(cell_template % html.escape(self.ToString(value[<NUM_LIT:1>])))<EOL><DEDENT>else:<EOL><INDENT>cells_list.append(cell_template % html.escape(self.ToString(value)))<EOL><DEDENT><DEDENT>rows_list.append(row_template % "<STR_LIT>".join(cells_list))<EOL><DEDENT>rows_html = rows_template % "<STR_LIT>".join(rows_list)<EOL>return table_template % (columns_html + rows_html)<EOL>
Writes the data table as an HTML table code string.

        Args:
          columns_order: Optional. Specifies the order of columns in the
                         output table. Specify a list of all column IDs in the order
                         in which you want the table created.
                         Note that you must list all column IDs in this parameter,
                         if you use it.
          order_by: Optional. Specifies the name of the column(s) to sort by.
                    Passed as is to _PreparedData.

        Returns:
          An HTML table code string.
          Example result (the result is without the newlines):
           <html><body><table border="1">
            <thead><tr><th>a</th><th>b</th><th>c</th></tr></thead>
            <tbody>
             <tr><td>1</td><td>"z"</td><td>2</td></tr>
             <tr><td>"3$"</td><td>"w"</td><td></td></tr>
            </tbody>
           </table></body></html>

        Raises:
          DataTableException: The data does not match the type.