Skip to content

Encode

rtflite.encode

RTFDocument

Bases: BaseModel

_page_by()

Create components for page_by format.

This method organizes data into sections based on the page_by grouping variables.

Returns:

Type Description
list[list[tuple[int, int, int]]]

A list of sections, where each section is a list of tuples (row_idx, col_idx, level).

list[list[tuple[int, int, int]]]

Each tuple represents:

list[list[tuple[int, int, int]]]
  • row_idx: The row index in the dataframe
list[list[tuple[int, int, int]]]
  • col_idx: The column index in the dataframe
list[list[tuple[int, int, int]]]
  • level: The nesting level of the section header.

_rtf_body_encode(df, rtf_attrs)

Convert the RTF table into RTF syntax using the Cell class.

Parameters:

Name Type Description Default
df DataFrame

Input DataFrame to encode

required
rtf_attrs TableAttributes | None

Table attributes for styling

required

Returns:

Type Description
MutableSequence[str]

List of RTF-encoded strings representing table rows

_rtf_font_table_encode()

Define RTF fonts

_rtf_page_encode()

Define RTF page settings

_rtf_page_margin_encode()

Define RTF margin settings

_rtf_title_encode(method)

Convert the RTF title into RTF syntax using the Text class.

rtf_encode()

Generate RTF code

write_rtf(file_path)

Write the RTF code into a .rtf file.