Format an Excel

Formats cells in an Excel worksheet.

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.

format the excel

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.

the worksheet name is "worksheet-name"

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"
the cell range is r

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"
the bg color is "bg-color-code"

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"
the font color is "font-color-code"

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"
the font weight is "font-weight"

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"
the font size is s

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

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"

Last updated

Was this helpful?