Export of Tables

<< Click to display table of contents >>

Export of Tables

Tables can be exported with document in the following formats:

text,

HTML,

RTF,

DocX

Markdown.

Text Export

Tables have the properties:

TextRowSeparator string to write after each row;

TextColSeparator string  to write between cells.

By default, the both of them are equal to CR+LF (#13#10).

MS Word 2000+ saves tables as text in the same way.

You can set TextColSeparator to TAB character (#09), if you wish, but do not forget that there can be CR+LFs inside cells.

RTF and DocX

TRichView saves tables in RTF according to the MS Word 2000+ standard. MS Word 2000 introduced many new RTF keywords to store HTML-like formatting.

Similar keywords are saved in DocX files.

MS Word supports two algorithms of calculating widths of columns: fixed and fit-by-content. Initial widths of table columns specified in RTF/DocX (called "table grid") are adjusted by MS Word according to the specified algorithm. The algorithm takes contents and widths of cells into account.

By default, TRichView saves tables as fixed tables. Generally, MS Word's fixed tables look closer to TRichView tables; however, there are some problems. For example, if we save exact values of Cells[r,c].BestWidth (specified in twips, EMU or pixels), MS Word sets width of these cells equal to these values exactly, so a wide content may be truncated. What's why TRichView does not save these values to RTF/DocX. So, after saving, cells having BestWidth = 0 and BestWidth > 0 are undistinguished, their width is taken from a table grid (which is saved according to table size in TRichView). You can turn on saving cells' BestWidth by including rvtoRTFSaveCellPixelBestWidth to table.Options; however, this is not recommended for fixed tables.

If you include rvtoRTFAllowAutofit in table.Options, this table will be saved as fit-by-content table (but only if table.BestWidth=0). For such tables, you can safely include rvtoRTFSaveCellPixelBestWidth to table.Options.

When saving a table grid to RTF/DocX, TRichView uses the current table size. What's why TRichView must be formatted before saving to RTF/DocX, if this document contains tables.

HTML

Some properties can be saved only with CSS (with TRichView.HTMLSaveProperties.HTMLSavingType = rvhtmlstNormal, or rvcsssoForceNonTextCSS in TRichView.HTMLSaveProperties.CSSOptions). See comments for table properties.

Markdown

The core Markdown specification does not support tables.

However, there is Markdown extension for tables. It can be activated by including rvmdeTables in TRichView.MarkdownProperties.Extensions (included by default).

Otherwise, content of table cells is saved as normal paragraphs.

See Also...

TRichView methods for saving and loading