Export of Tables
|Top Previous Next|
Tables can be exported with document in the following formats:
Tables have the properties:
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
RichView 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 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.
TRichView © trichview.com