'Add content of a table to the report.
The method accepts different kinds of two-dimensional data, including
Qt\'s views and models.
The first argument, `name` can be omitted if other arguments (except
`table`) are passed as keyword arguments.
:param name: name of the section
:type name: str
:param table: table to be reported
:type table:
QAbstractItemModel or QStandardItemModel or two-dimensional list or
any object with method `model()` that returns one of the above
:param header_rows: the number of rows that are marked as header rows
:type header_rows: int
:param header_columns:
the number of columns that are marked as header columns
:type header_columns: int
:param num_format: numeric format, e.g. `{:.3}`'

def report_table(self, name, table=None, header_rows=0, header_columns=0, num_format=None):

    row_limit = 100
    (name, table) = self._fix_args(name, table)
    join = ''.join
    def data(item):
        return ((item and item.data(Qt.DisplayRole)) or '')
    def report_abstract_model(model, view=None):
        columns = [i for i in range(model.columnCount()) if ((not view) or (not view.isColumnHidden(i)))]
        rows = [i for i in range(model.rowCount()) if ((not view) or (not view.isRowHidden(i)))]
        has_horizontal_header = (try_((lambda : (not view.horizontalHeader().isHidden()))) or try_((lambda : (not view.header().isHidden()))))
        has_vertical_header = try_((lambda : (not view.verticalHeader().isHidden())))
        def item_html(row, col):
            def data(role=Qt.DisplayRole, orientation=(Qt.Horizontal if (row is None) else Qt.Vertical)):
                if ((row is None) or (col is None)):
                    return model.headerData((col if (row is None) else row), orientation, role)
                return model.data(model.index(row, col), role)
            selected = (view.selectionModel().isSelected(model.index(row, col)) if (view and (row is not None) and (col is not None)) else False)
            fgcolor = data(Qt.ForegroundRole)
            fgcolor = (QBrush(fgcolor).color().name() if isinstance(fgcolor, (QBrush, QColor)) else 'black')
            bgcolor = data(Qt.BackgroundRole)
            bgcolor = (QBrush(bgcolor).color().name() if isinstance(bgcolor, (QBrush, QColor)) else 'transparent')
            if (bgcolor.lower() == '#ffffff'):
                bgcolor = 'transparent'
            font = data(Qt.FontRole)
            weight = ('bold' if (font and font.bold()) else 'normal')
            alignment = (data(Qt.TextAlignmentRole) or Qt.AlignLeft)
            halign = ('left' if (alignment & Qt.AlignLeft) else ('right' if (alignment & Qt.AlignRight) else 'center'))
            valign = ('top' if (alignment & Qt.AlignTop) else ('bottom' if (alignment & Qt.AlignBottom) else 'middle'))
            return '<{tag}    style="color:{fgcolor};border:{border};background:{bgcolor};font-weight:{weight};text-align:{halign};vertical-align:{valign};">{text}</{tag}>'.format(tag=('th' if ((row is None) or (col is None)) else 'td'), border=('1px    solid    black' if selected else '0'), text=(data() or ''), weight=weight, fgcolor=fgcolor, bgcolor=bgcolor, halign=halign, valign=valign)
        stream = []
        if has_horizontal_header:
            stream.append('<tr>')
            if has_vertical_header:
                stream.append('<th></th>')
            stream.extend((item_html(None, col) for col in columns))
            stream.append('</tr>')
        for row in rows[:row_limit]:
            stream.append('<tr>')
            if has_vertical_header:
                stream.append(item_html(row, None))
            stream.extend((item_html(row, col) for col in columns))
            stream.append('</tr>')
        return ''.join(stream)
    if num_format:
        def fmtnum(s):
            try:
                return num_format.format(float(s))
            except:
                return s
    else:
        def fmtnum(s):
            return s
    def report_list(data, header_rows=header_rows, header_columns=header_columns):
        cells = ['<td>{}</td>', '<th>{}</th>']
        return join(('        <tr>\n                {}</tr>\n'.format(join((cells[((rowi < header_rows) or (coli < header_columns))].format(fmtnum(elm)) for (coli, elm) in enumerate(row)))) for (rowi, row) in zip(range((row_limit + header_rows)), data)))
    self.report_name(name)
    (n_hidden_rows, n_cols) = (0, 1)
    if isinstance(table, QTableView):
        body = report_abstract_model(table.model(), table)
        n_hidden_rows = (table.model().rowCount() - row_limit)
        n_cols = table.model().columnCount()
    elif isinstance(table, QAbstractItemModel):
        body = report_abstract_model(table)
        n_hidden_rows = (table.rowCount() - row_limit)
        n_cols = table.columnCount()
    elif isinstance(table, Iterable):
        body = report_list(table, header_rows, header_columns)
        table = list(table)
        n_hidden_rows = len(table)
        if (len(table) and isinstance(table[0], Iterable)):
            n_cols = len(table[0])
    else:
        body = None
    if (n_hidden_rows > 0):
        body += "<tr><th></th><td    colspan='{}'><b>+    {}    more</b></td></tr>\n                                                ".format(n_cols, n_hidden_rows)
    if body:
        self.report_html += (('<table>\n' + body) + '</table>')
