# GC.Spread.Sheets.Tables.TableColumn

## Content

# Class: TableColumn

[Sheets](../modules/GC.Spread.Sheets).[Tables](../modules/GC.Spread.Sheets.Tables).TableColumn

## Table of contents

### Constructors

- [constructor](GC.Spread.Sheets.Tables.TableColumn#constructor)

### Methods

- [cellType](GC.Spread.Sheets.Tables.TableColumn#celltype)
- [dataField](GC.Spread.Sheets.Tables.TableColumn#datafield)
- [dataStyle](GC.Spread.Sheets.Tables.TableColumn#datastyle)
- [footerStyle](GC.Spread.Sheets.Tables.TableColumn#footerstyle)
- [formatter](GC.Spread.Sheets.Tables.TableColumn#formatter)
- [headerStyle](GC.Spread.Sheets.Tables.TableColumn#headerstyle)
- [id](GC.Spread.Sheets.Tables.TableColumn#id)
- [name](GC.Spread.Sheets.Tables.TableColumn#name)
- [value](GC.Spread.Sheets.Tables.TableColumn#value)

## Constructors

### <a id="constructor" name="constructor"></a> constructor

• **new TableColumn**(`id`, `dataField?`, `name?`, `formatter?`, `cellType?`, `value?`, `dataStyle?`, `headerStyle?`, `footerStyle?`)

Represents the table column information.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `id` | `number` | The table column ID. |
| `dataField?` | `string` | The table column data field. |
| `name?` | `string` | The table column name. |
| `formatter?` | `string` | The table column formatter. |
| `cellType?` | [`Base`](GC.Spread.Sheets.CellTypes.Base) | The table column cellType. |
| `value?` | `Function` | The table column value convert function. |
| `dataStyle?` | `string` \| [`Style`](GC.Spread.Sheets.Style) | the data style of the table column |
| `headerStyle?` | `string` \| [`Style`](GC.Spread.Sheets.Style) | the header style of the table column |
| `footerStyle?` | `string` \| [`Style`](GC.Spread.Sheets.Style) | the footer style of the table column |

## Methods

### <a id="celltype" name="celltype"></a> cellType

▸ **cellType**(`value?`): `any`

Gets or sets the table column cellType for custom cell type.

**`example`**
```
var data = {
     sales: [
         { name: 'Pencil', isMakeMoney: true },
         { name: 'Binder', isMakeMoney: true },
         { name: 'Pen Set', isMakeMoney: false }
     ]
 };
 var table = sheet.tables.add('tableSales', 0, 0, 5, 2);
 var tableColumn1 = new GC.Spread.Sheets.Tables.TableColumn();
 tableColumn1.name("name");
 tableColumn1.dataField("name");
 var tableColumn2 = new GC.Spread.Sheets.Tables.TableColumn();
 tableColumn2.name("IsMakeMoney");
 tableColumn2.dataField("isMakeMoney");
 tableColumn2.cellType(new GC.Spread.Sheets.CellTypes.CheckBox());
 table.autoGenerateColumns(false);
 table.bind([tableColumn1, tableColumn2], 'sales', data);
```

#### Parameters

| Name | Type |
| :------ | :------ |
| `value?` | [`Base`](GC.Spread.Sheets.CellTypes.Base) |

#### Returns

`any`

If no value is set, returns the table column cellType; otherwise, returns the table column.

___

### <a id="datafield" name="datafield"></a> dataField

▸ **dataField**(`value?`): `any`

Gets or sets the table column data field for accessing the table's data source.

**`example`**
```
var data = {
     sales: [
         { name: 'Pencil' },
         { name: 'Binder' },
         { name: 'Pen Set' }
     ]
 };
 var table = sheet.tables.add('tableSales', 0, 0, 5, 2);
 var tableColumn1 = new GC.Spread.Sheets.Tables.TableColumn();
 tableColumn1.name("name");
 tableColumn1.dataField("name");
 table.bind([tableColumn1], 'sales', data);
```

#### Parameters

| Name | Type |
| :------ | :------ |
| `value?` | `string` |

#### Returns

`any`

If no value is set, returns the table column data field; otherwise, returns the table column.

___

### <a id="datastyle" name="datastyle"></a> dataStyle

▸ **dataStyle**(`value?`): `any`

Gets or sets the table column dataStyle.

#### Parameters

| Name | Type |
| :------ | :------ |
| `value?` | `string` \| [`Style`](GC.Spread.Sheets.Style) |

#### Returns

`any`

If no value is set, returns the table column dataStyle; otherwise, returns the table column.

___

### <a id="footerstyle" name="footerstyle"></a> footerStyle

▸ **footerStyle**(`value?`): `any`

Gets or sets the table column footerStyle.

#### Parameters

| Name | Type |
| :------ | :------ |
| `value?` | `string` \| [`Style`](GC.Spread.Sheets.Style) |

#### Returns

`any`

If no value is set, returns the table column footerStyle; otherwise, returns the table column.

___

### <a id="formatter" name="formatter"></a> formatter

▸ **formatter**(`value?`): `any`

Gets or sets the table column formatter for format display value.

**`example`**
```
var data = {
     sales: [
         { name: 'Pencil', orderDate: new Date(2013, 3, 1) },
         { name: 'Binder', orderDate: new Date(2013, 4, 1) },
         { name: 'Pen Set', orderDate: new Date(2013, 6, 8) }
     ]
 };
 var table = sheet.tables.add('tableSales', 0, 0, 5, 2);
 var tableColumn1 = new GC.Spread.Sheets.Tables.TableColumn();
 tableColumn1.name("name");
 tableColumn1.dataField("name");
 var tableColumn2 = new GC.Spread.Sheets.Tables.TableColumn();
 tableColumn2.name("Order Date");
 tableColumn2.dataField("orderDate");
 tableColumn2.formatter("d/M/yy");
 table.autoGenerateColumns(false);
 table.bind([tableColumn1, tableColumn2], 'sales', data);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `value?` | `string` | The table column formatter. |

#### Returns

`any`

If no value is set, returns the table column formatter; otherwise, returns the table column.

___

### <a id="headerstyle" name="headerstyle"></a> headerStyle

▸ **headerStyle**(`value?`): `any`

Gets or sets the table column headerStyle.

#### Parameters

| Name | Type |
| :------ | :------ |
| `value?` | `string` \| [`Style`](GC.Spread.Sheets.Style) |

#### Returns

`any`

If no value is set, returns the table column headerStyle; otherwise, returns the table column.

___

### <a id="id" name="id"></a> id

▸ **id**(`value?`): `any`

Gets or sets the table column ID.

**`example`**
```
var data = {
     sales: [
         { name: 'Pencil' },
         { name: 'Binder' },
         { name: 'Pen Set' }
     ]
 };
 var table = sheet.tables.add('tableSales', 0, 0, 5, 2);
 var tableColumn1 = new GC.Spread.Sheets.Tables.TableColumn();
 tableColumn1.id("name");
 tableColumn1.dataField("name");
 table.bind([tableColumn1], 'sales', data);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `value?` | `number` | The table column ID. |

#### Returns

`any`

If no value is set, returns the table column ID; otherwise, returns the table column.

___

### <a id="name" name="name"></a> name

▸ **name**(`value?`): `any`

Gets or sets the table column name for display.

**`example`**
```
var data = {
     sales: [
         { name: 'Pencil' },
         { name: 'Binder' },
         { name: 'Pen Set' }
     ]
 };
 var table = sheet.tables.add('tableSales', 0, 0, 5, 2);
 var tableColumn1 = new GC.Spread.Sheets.Tables.TableColumn();
 tableColumn1.name("name");
 tableColumn1.dataField("name");
 table.bind([tableColumn1], 'sales', data);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `value?` | `string` | The table column name. |

#### Returns

`any`

If no value is set, returns the table column name; otherwise, returns the table column.

___

### <a id="value" name="value"></a> value

▸ **value**(`value?`): `Function`

Gets or sets the table column value convert function for display value.

**`example`**
```
var data = {
     sales: [
         { name: 'Pencil', orderDate: new Date(2013, 3, 1), cost: 1.99 },
         { name: 'Binder', orderDate: new Date(2013, 4, 1), cost: 4.99 },
         { name: 'Pen Set', orderDate: new Date(2013, 6, 8), cost: 15.99 }
     ]
 };
 var table = sheet.tables.add('tableSales', 0, 0, 5, 3);
 var tableColumn1 = new GC.Spread.Sheets.Tables.TableColumn();
 tableColumn1.name("name");
 tableColumn1.dataField("name");
 var tableColumn2 = new GC.Spread.Sheets.Tables.TableColumn();
 tableColumn2.name("Order Date");
 tableColumn2.dataField("orderDate");
 tableColumn2.formatter("d/M/yy");
 var tableColumn3 = new GC.Spread.Sheets.Tables.TableColumn();
 tableColumn3.name("Cost");
 tableColumn3.dataField("cost");
 tableColumn3.value(function (item) {
     return item['cost'] + '$';
 });
 table.autoGenerateColumns(false);
 table.bind([tableColumn1, tableColumn2, tableColumn3], 'sales', data);
```

#### Parameters

| Name | Type |
| :------ | :------ |
| `value?` | `Function` |

#### Returns

`Function`

If no value is set, returns the table column value convert function; otherwise, returns the table column.
