# Tables

### Overview

This procedure locates and extracts a table from an Excel worksheet.

### Syntax

Below is a line-by-line overview of the automation syntax. Expand each line to learn more.

<details>

<summary><code>extract a table from the worksheet</code></summary>

#### What does it do?

Begins table extraction from the current worksheet.

#### Where does it go?

This phrase should be written on a **new line**.

#### Is it required?

✅ Yes — This phrase is **required**.

#### Does it require data?

✅ Yes — A reference to **the worksheet** must be defined in the automation.

</details>

<details>

<summary><code>the description is "table-description"</code></summary>

#### What does it do?

Describes the table to be extracted.

#### Where does it go?

Indented under `extract a table from the worksheet where`.

#### Is it required?

❌ No — This phrase is **optional**.

#### Does it require data?

✅ Yes — Replace **table-description** with a text description of the table you want to extract.

#### Example

```
the description is "sales data with monthly totals"
```

</details>

<details>

<summary><code>the location is "A1:D10"</code></summary>

#### What does it do?

Specifies the cell range containing the table.

#### Where does it go?

Indented under `extract a table from the worksheet where`.

#### Is it required?

❌ No — This phrase is **optional**.

#### Does it require data?

✅ Yes — Replace **A1:D10** with a cell range in Excel format that specifies the top-left and bottom-right corners of the table.

#### Example

```
the location is "A1:D10"
```

</details>

<details>

<summary><code>the first header is "x"</code></summary>

#### What does it do?

Specifies the leftmost column header to start extraction.

#### Where does it go?

Indented under `extract a table from the worksheet where`.

#### Is it required?

❌ No — This phrase is **optional**.

#### Does it require data?

✅ Yes — Replace **x** with the name of the first column header.

#### Example

```
the first header is "Name"
```

</details>

<details>

<summary><code>the last header is "y"</code></summary>

#### What does it do?

Specifies the rightmost column header to end extraction.

#### Where does it go?

Indented under `extract a table from the worksheet where`.

#### Is it required?

❌ No — This phrase is **optional**.

#### Does it require data?

✅ Yes — Replace **y** with the name of the last column header.

#### Example

```
the last header is "Total"
```

</details>

<details>

<summary><code>the first header location is "A6"</code></summary>

#### What does it do?

Specifies the exact cell location of the first header.

#### Where does it go?

Indented under `extract a table from the worksheet where`.

#### Is it required?

❌ No — This phrase is **optional**.

#### Does it require data?

✅ Yes — Replace **A6** with an Excel cell reference where the first header is located. Must be on the same row as the last header location.

#### Example

```
the first header location is "A6"
```

</details>

<details>

<summary><code>the last header location is "DR6"</code></summary>

#### What does it do?

Specifies the exact cell location of the last header.

#### Where does it go?

Indented under `extract a table from the worksheet where`.

#### Is it required?

❌ No — This phrase is **optional**.

#### Does it require data?

✅ Yes — Replace **DR6** with an Excel cell reference where the last header is located. Must be on the same row as the first header location.

#### Example

```
the last header location is "DR6"
```

</details>

<details>

<summary><code>the row count is 40000</code></summary>

#### What does it do?

Limits the number of data rows to extract (excluding header).

#### Where does it go?

Indented under `extract a table from the worksheet where`.

#### Is it required?

❌ No — This phrase is **optional**.

#### Does it require data?

✅ Yes — Replace **40000** with the number of data rows to extract. If omitted, extracts to the end of the worksheet.

#### Example

```
the row count is 40000
```

</details>

<details>

<summary><code>the openai model is "openai-model"</code></summary>

#### What does it do?

Specifies the OpenAI model to use for AI-powered table extraction.

#### Where does it go?

Indented under `extract a table from the worksheet where`.

#### Is it required?

❌ No — This phrase is **optional**.

#### Does it require data?

✅ Yes — Replace **openai-model** with a valid OpenAI model name.

#### Example

```
the openai model is "gpt-4o"
```

</details>

<details>

<summary><code>the gemini model is "gemini-model"</code></summary>

#### What does it do?

Specifies the Gemini model to use for AI-powered table extraction.

#### Where does it go?

Indented under `extract a table from the worksheet where`.

#### Is it required?

❌ No — This phrase is **optional**.

#### Does it require data?

✅ Yes — Replace **gemini-model** with a valid Gemini model name.

#### Example

```
the gemini model is "gemini-2.0-flash"
```

</details>

### Examples

#### 1. Extract Table by Description

```
extract a table from the worksheet where
    the description is "This is a table which calculates housing cost information"
```

#### 2. Extract Table by Cell Range

Extracts a table from a specific cell range.

```
extract a table from the worksheet where
    the location is "A1:D15"
```

#### 3. Extract Table by Header Range

Extracts a table between specified column headers.

```
extract a table from the worksheet where
    the first header is "Employee ID"
    the last header is "Department"
```

#### 4. Extract Table by Header Locations (Fast)

Extracts a table using exact header cell locations - faster than header name matching.

```
extract a table from the worksheet where
    the first header location is "A6"
    the last header location is "DR6"
```

#### 5. Extract Table by Header Locations with Row Limit

Extracts a table using header locations with a specific number of data rows.

```
extract a table from the worksheet where
    the first header location is "A6"
    the last header location is "DR6"
    the row count is 40000
```

#### 6. Extract Table by Description with Custom Model

Extracts a table using AI-powered description with a specific model.

```
extract a table from the worksheet where
    the description is "Sales data table with monthly revenue and profit columns"
    the openai model is "gpt-4o"
```
