Body
Body, root of the document content.
Classes:
| Name | Description |
|---|---|
Body |
Root of the document content, “office:body”. |
Chart |
Root of the Chart document content, “office:chart”. |
Database |
Root of the Database document content, “office:database”. |
Drawing |
Root of the Drawing document content, “office:drawing”. |
Image |
Root of the Image document content, “office:image”. |
Metadata |
Root of the Meta document content, “office:meta”. |
OfficeSettings |
Root of the Settings document content, “office:settings”. |
Presentation |
Root of the Presentation document content, “office:presentation”. |
Spreadsheet |
Root of the Spreadsheet document content, “office:spreadsheet”. |
Text |
Root of the Text document content, “office:text”. |
Attributes:
| Name | Type | Description |
|---|---|---|
BODY_NR_TAGS |
|
BODY_NR_TAGS
module-attribute
BODY_NR_TAGS = BODY_ALLOW_NAMED_RANGE_TAGS
Body
Bases: Element
Root of the document content, “office:body”.
Methods:
| Name | Description |
|---|---|
get_table |
Return the table that matches the criteria. |
get_tables |
Return all the tables that match the criteria. |
Attributes:
| Name | Type | Description |
|---|---|---|
allow_named_range |
bool
|
Return True if the current body allows named ranges. |
get_sheet |
|
|
get_sheets |
|
|
sheets |
|
|
tables |
list[Table]
|
Return all the tables. |
Source code in odfdo/body.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = ()
_tag
class-attribute
instance-attribute
_tag: str = 'office:body'
allow_named_range
property
allow_named_range: bool
Return True if the current body allows named ranges.
get_sheet
class-attribute
instance-attribute
get_sheet = get_table
get_sheets
class-attribute
instance-attribute
get_sheets = get_tables
sheets
class-attribute
instance-attribute
sheets = tables
tables
property
tables: list[Table]
get_table
get_table(
position: int = 0,
name: str | None = None,
content: str | None = None,
) -> Table | None
Return the table that matches the criteria.
The method is also accessible via the alias get_sheet().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
int
|
The 0-based index of the table to retrieve among the matching tables. Defaults to 0. |
0
|
name
|
str | None
|
The name of the table to match. |
None
|
content
|
str | None
|
A regex pattern to match within the table content. |
None
|
Returns:
| Type | Description |
|---|---|
Table | None
|
Table or None: The matching Table element, or None if not found. |
Source code in odfdo/body.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
get_tables
get_tables(
style: str | None = None, content: str | None = None
) -> list[Table]
Return all the tables that match the criteria.
The method is also accessible via the alias get_sheets().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
style
|
str | None
|
The style name of the tables to match. |
None
|
content
|
str | None
|
A regex pattern to match within the table content. |
None
|
Returns:
| Type | Description |
|---|---|
list[Table]
|
list[Table]: A list of matching Table elements. |
Source code in odfdo/body.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
Chart
Bases: UserFieldDeclContMixin, VarDeclMixin, NRMixin, Body
Root of the Chart document content, “office:chart”.
Source code in odfdo/body.py
131 132 133 134 135 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = ()
_tag
class-attribute
instance-attribute
_tag: str = 'office:chart'
Database
Bases: Body
Root of the Database document content, “office:database”.
Source code in odfdo/body.py
138 139 140 141 142 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = ()
_tag
class-attribute
instance-attribute
_tag: str = 'office:database'
Drawing
Bases: UserFieldDeclContMixin, VarDeclMixin, NRMixin, Body
Root of the Drawing document content, “office:drawing”.
Source code in odfdo/body.py
145 146 147 148 149 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = ()
_tag
class-attribute
instance-attribute
_tag: str = 'office:drawing'
Image
Bases: Body
Root of the Image document content, “office:image”.
Source code in odfdo/body.py
152 153 154 155 156 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = ()
_tag
class-attribute
instance-attribute
_tag: str = 'office:image'
Metadata
Bases: Body
Root of the Meta document content, “office:meta”.
Source code in odfdo/body.py
207 208 209 210 211 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = ()
_tag
class-attribute
instance-attribute
_tag: str = 'office:meta'
OfficeSettings
Bases: Body
Root of the Settings document content, “office:settings”.
Methods:
| Name | Description |
|---|---|
as_dict |
Serialize the OfficeSettings element and its children to a dictionary. |
from_dict |
Create an OfficeSettings element from a dictionary representation. |
Source code in odfdo/body.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = ()
_tag
class-attribute
instance-attribute
_tag: str = 'office:settings'
as_dict
as_dict() -> dict[
str, str | int | bool | dict[str, Any] | list[Any]
]
Serialize the OfficeSettings element and its children to a dictionary.
This method recursively converts the element and its child elements
(if they also have an as_dict method) into a dictionary
representation.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, str | int | bool | dict[str, Any] | list[Any]]
|
A dictionary representing the OfficeSettings element, where the key is the element’s tag and the value is a dictionary containing its children’s representations. |
Source code in odfdo/body.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
from_dict
classmethod
from_dict(
data: dict[str, str | int | bool | dict[str, Any]],
) -> OfficeSettings
Create an OfficeSettings element from a dictionary representation.
This class method reconstructs an OfficeSettings element and its
children from a dictionary previously generated by a method like
as_dict(). It leverages an internal helper _from_dict for the
actual conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, str | int | bool | dict[str, Any]]
|
A dictionary containing the representation of the OfficeSettings element, including its tag and children. |
required |
Returns:
| Type | Description |
|---|---|
OfficeSettings
|
An OfficeSettings instance populated with data from the dictionary. |
Source code in odfdo/body.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
Presentation
Bases: UserDefinedMixin, UserFieldDeclContMixin, LinkMixin, VarDeclMixin, NRMixin, Body
Root of the Presentation document content, “office:presentation”.
Source code in odfdo/body.py
159 160 161 162 163 164 165 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = ()
_tag
class-attribute
instance-attribute
_tag: str = 'office:presentation'
Spreadsheet
Bases: UserDefinedMixin, UserFieldDeclContMixin, VarDeclMixin, LinkMixin, AnnotationMixin, NRMixin, Body
Root of the Spreadsheet document content, “office:spreadsheet”.
Source code in odfdo/body.py
168 169 170 171 172 173 174 175 176 177 178 179 180 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = ()
_tag
class-attribute
instance-attribute
_tag: str = 'office:spreadsheet'
Text
Bases: ListMixin, TocMixin, UserDefinedMixin, UserFieldDeclContMixin, LinkMixin, VarDeclMixin, NRMixin, FormMixin, TrackedChangesMixin, OfficeFormsMixin, SectionMixin, ReferenceMixin, BookmarkMixin, AnnotationMixin, NoteMixin, Body
Root of the Text document content, “office:text”.
Source code in odfdo/body.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = ()
_tag
class-attribute
instance-attribute
_tag: str = 'office:text'