# Tables

### *class* Tables

A collection of all `table` objects on the specified sheet:

```pycon
>>> # Assumes an existing workbook object named book.
>>> book.sheets[0].tables
Tables([<Table 'Table1' in Sheet1>,
        <Table 'Table2' in Sheet1>])
```

#### Versionadded
Added in version 0.21.0.

#### add(source=None, name=None, source_type=None, link_source=None, has_headers=True, destination=None, table_style_name='TableStyleMedium2')

指定したシートに新しいTableを作成します。

* **パラメータ:**
  * **source** ([*Range*](range.md#xlwings.Range) *|* *None*) -- データ ソースを表すxlwingsのrangeオブジェクト。
  * **name** (*str* *|* *None*) -- テーブルの名前。デフォルトはExcelが自動生成する名前。
  * **source_type** (*str* *|* *None*) -- 現在のところ、デフォルトは `xlSrcRange` 。つまり、xlwingsのrangeオブジェクトの使用を前提とするものです。他のオプションは使用できません。
  * **link_source** (*bool* *|* *None*) -- `source_type` が `xlSrcExternal` の時に使用するものなので、現在時点では実装されていません。
  * **has_headers** (*bool*) -- Whether the source range has column labels. Defaults to `True`. When `False`, Excel generates headers above the source data.
  * **destination** ([*Range*](range.md#xlwings.Range) *|* *None*) -- `source_type` が `xlSrcExternal` の時に使用するものなので、現在時点では実装されていません。
  * **table_style_name** (*str*) -- Possible strings: `'TableStyleLightN'` (where N is 1-21),
    `'TableStyleMediumN'` (where N is 1-28),
    `'TableStyleDarkN'` (where N is 1-11)
* **戻り値の型:**
  [*Table*](table.md#xlwings.main.Table)

### サンプル

```pycon
>>> # Assumes an existing workbook object named book.
>>> sheet = book.sheets[0]
>>> sheet['A1'].value = [['a', 'b'], [1, 2]]
>>> table = sheet.tables.add(source=sheet['A1'].expand(), name='MyTable')
>>> table
<Table 'MyTable' in Sheet1>
```

#### *property* api *: Any*

Returns the native object (`pywin32` or `appscript` obj)
of the engine being used.

#### *property* count *: int*

コレクションに含まれるオブジェクトの数を返します。
