Selection: Formatting#

For certain formats (notably xls and xlsx) selecting based on cell format is also supported.

The following are example methods:

  • is_bold / is_not_bold: Does the cell have bold formatting.

  • is_indented / is_not_indented: Does the cell have indented text.

  • is_italic / is_not_italic: Does the cell have italic formatting.

  • is_underline / is_not_underline: Does the cell have underline formatting.

  • is_hyperlink / is_hyperlink Is the cell a hyperlink.

We’ll use the following sample file as a simple example:

from tidychef import acquire, preview

# Acquire the XLSX file
table = acquire.xlsx.http("https://raw.githubusercontent.com/mikeAdamss/tidychef/main/tests/fixtures/xlsx/simple-formatting.xlsx", tables="Sheet1")
preview(table)

Sheet1

ABCDEF
1
2
3I am bold!
4itallic text
5
6www.google.com
7Underlined text
8
9
10no formatting
11no formattingindett 1
12indent 2

Now we’ll make some simple conditional selections via the format based methods.

bold_cells = table.is_bold().label_as("Bold")
italic_cells = table.is_italic().label_as("Italic")
underlined_cells = table.is_underline().label_as("Underlined")
hyperlink_cells = table.is_hyperlink().label_as("Hypterlinked")
indented_cells = table.is_indented().label_as("Indented")

preview(bold_cells, italic_cells, underlined_cells, hyperlink_cells, indented_cells)
Bold
Italic
Underlined
Hypterlinked
Indented

Sheet1

ABCDEF
1
2
3I am bold!
4itallic text
5
6www.google.com
7Underlined text
8
9
10no formatting
11no formattingindett 1
12indent 2