Next: Validating OpenDocument XML, Previous: Creating one-off styles, Up: Advanced topics in ODT export [Contents][Index]
You can override the default formatting of the table by specifying a custom
table style with the #+ATTR_ODT
line. For a discussion on default
formatting of tables see Tables in ODT export.
This feature closely mimics the way table templates are defined in the OpenDocument-v1.2 specification.157
To have a quick preview of this feature, install the below setting and export the table that follows:
(setq org-odt-table-styles (append org-odt-table-styles '(("TableWithHeaderRowAndColumn" "Custom" ((use-first-row-styles . t) (use-first-column-styles . t))) ("TableWithFirstRowandLastRow" "Custom" ((use-first-row-styles . t) (use-last-row-styles . t))))))
#+ATTR_ODT: :style "TableWithHeaderRowAndColumn" | Name | Phone | Age | | Peter | 1234 | 17 | | Anna | 4321 | 25 |
In the above example, you used a template named ‘Custom’ and installed two table styles with the names ‘TableWithHeaderRowAndColumn’ and ‘TableWithFirstRowandLastRow’. (Important: The OpenDocument styles needed for producing the above template have been pre-defined for you. These styles are available under the section marked ‘Custom Table Template’ in OrgOdtContentTemplate.xml (see Factory styles). If you need additional templates you have to define these styles yourselves.
To use this feature proceed as follows:
A table template is nothing but a set of ‘table-cell’ and ‘paragraph’ styles for each of the following table cell categories:
The names for the above styles must be chosen based on the name of the table template using a well-defined convention.
The naming convention is better illustrated with an example. For a table template with the name ‘Custom’, the needed style names are listed in the following table.
Table cell type | table-cell style | paragraph style |
---|---|---|
Body | ‘CustomTableCell’ | ‘CustomTableParagraph’ |
First column | ‘CustomFirstColumnTableCell’ | ‘CustomFirstColumnTableParagraph’ |
Last column | ‘CustomLastColumnTableCell’ | ‘CustomLastColumnTableParagraph’ |
First row | ‘CustomFirstRowTableCell’ | ‘CustomFirstRowTableParagraph’ |
Last row | ‘CustomLastRowTableCell’ | ‘CustomLastRowTableParagraph’ |
Even row | ‘CustomEvenRowTableCell’ | ‘CustomEvenRowTableParagraph’ |
Odd row | ‘CustomOddRowTableCell’ | ‘CustomOddRowTableParagraph’ |
Even column | ‘CustomEvenColumnTableCell’ | ‘CustomEvenColumnTableParagraph’ |
Odd column | ‘CustomOddColumnTableCell’ | ‘CustomOddColumnTableParagraph’ |
To create a table template with the name ‘Custom’, define the above
styles in the
<office:automatic-styles>
...</office:automatic-styles>
element
of the content template file (see Factory
styles).
To define a table style, create an entry for the style in the variable
org-odt-table-styles
and specify the following:
For example, the entry below defines two different table styles ‘TableWithHeaderRowAndColumn’ and ‘TableWithFirstRowandLastRow’ based on the same template ‘Custom’. The styles achieve their intended effect by selectively activating the individual cell styles in that template.
(setq org-odt-table-styles (append org-odt-table-styles '(("TableWithHeaderRowAndColumn" "Custom" ((use-first-row-styles . t) (use-first-column-styles . t))) ("TableWithFirstRowandLastRow" "Custom" ((use-first-row-styles . t) (use-last-row-styles . t))))))
To do this, specify the table style created in step (2) as part of
the ATTR_ODT
line as shown below.
#+ATTR_ODT: :style "TableWithHeaderRowAndColumn" | Name | Phone | Age | | Peter | 1234 | 17 | | Anna | 4321 | 25 |
OpenDocument-v1.2 Specification
See the <table:table-template>
element of the OpenDocument-v1.2 specification
See the attributes table:template-name
,
table:use-first-row-styles
, table:use-last-row-styles
,
table:use-first-column-styles
, table:use-last-column-styles
,
table:use-banding-rows-styles
, and
table:use-banding-column-styles
of the <table:table>
element in
the OpenDocument-v1.2 specification
Next: Validating OpenDocument XML, Previous: Creating one-off styles, Up: Advanced topics in ODT export [Contents][Index]