# Format an Excel

### Overview

This procedure formats cells in an Excel worksheet by applying various formatting options such as background color, font color, font weight, and font size to specified cell ranges.

### Syntax

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

<details>

<summary><code>format the excel</code></summary>

#### What does it do?

Begins formatting cells in the Excel file.

#### 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 excel** file must be defined in the automation.

</details>

<details>

<summary><code>the worksheet name is "worksheet-name"</code></summary>

#### What does it do?

Specifies which worksheet to format.

#### Where does it go?

Indented under `format the excel`.

#### Is it required?

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

#### Does it require data?

✅ Yes — Replace **worksheet-name** with the name of an existing worksheet.

#### Example

```
the worksheet name is "Sheet1"
```

</details>

<details>

<summary><code>the cell range is r</code></summary>

#### What does it do?

Specifies which cells to format.

#### Where does it go?

Indented under `format the excel`.

#### Is it required?

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

#### Does it require data?

✅ Yes — Replace **r** with a cell range (e.g., "A1:B10") or single cell (e.g., "A1").

#### Example

```
the cell range is "A1:C5"
```

</details>

<details>

<summary><code>the bg color is "bg-color-code"</code></summary>

#### What does it do?

Sets the background color of the cells.

#### Where does it go?

Indented under `format the excel`.

#### Is it required?

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

#### Does it require data?

✅ Yes — Replace **bg-color-code** with a hex color code *(without "#")*.

#### Example

```
the bg color is "FFFF00"
```

</details>

<details>

<summary><code>the font color is "font-color-code"</code></summary>

#### What does it do?

Sets the font color of the cells.

#### Where does it go?

Indented under `format the excel`.

#### Is it required?

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

#### Does it require data?

✅ Yes — Replace **font-color-code** with a hex color code *(without "#")*.

#### Example

```
the font color is "000000"
```

</details>

<details>

<summary><code>the font weight is "font-weight"</code></summary>

#### What does it do?

Sets the font weight/style.

#### Where does it go?

Indented under `format the excel`.

#### Is it required?

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

#### Does it require data?

✅ Yes — Replace **font-weight** with "bold", "italic", "underline", or "strike".

#### Example

```
the font weight is "bold"
```

</details>

<details>

<summary><code>the font size is s</code></summary>

#### What does it do?

Sets the font size in points.

#### Where does it go?

Indented under `format the excel`.

#### Is it required?

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

#### Does it require data?

✅ Yes — Replace **s** with a numeric value.

#### Example

```
the font size is 14
```

</details>

### Examples

#### 1. Format Header Row with Background and Bold Font

Formats header cells with yellow background and bold text.

```
format the excel
    the worksheet name is "Sheet1"
    the cell range is "A1:C5"
    the bg color is "FFFF00"
    the font color is "000000"
    the font weight is "bold"
```

#### 2. Format Data Column with Font Size and Color

Formats a data column with larger font size and blue color.

```
format the excel
    the worksheet name is "Sheet1"
    the cell range is "A1:A10"
    the font size is 14
    the font color is "0000FF"
```
