Example 64 : Using TAdvGridRTFIO for native RTF export
With the TAdvGridRTFIO component it is possible to export a grid to a RTF file without the need to have any other software installed such as MS Word. TAdvGridRTFIO is an add-on component that is included with TAdvStringGrid. It is a separate component and as such, when not used, the RTF capabilities do not increase your application executable size unnecessarily.
Using TAdvGridRTFIO is very simple. Drop the component on the form and assign your TAdvStringGrid or descendent component to the TAdvGridRTFIO.AdvStringGrid property. Call TAdvGridRTFIO.ExportRTF(FileName) to do the actual export.
Options for the export are controlled by various TAdvGridRTFIO properties:
GridStartCol, GridStartRow: sets the top left row from where the export should start. With this property you can control whether fixed cells are exported or not.
ConvertHTML When true, HTML formatted cell text is automatically converted to rich text formatting otherwise the cell text is exported without any attributes ExportBackground When true, grid cell background colors are exported ExportCellProperties When true, grid cell properties such as font style, name, size & alignment are exported ExportHiddenColumns When true, hidden cells are also exported ExportImages When true, images are exported ExportMSWordFeatures When true, MS Word specific rich text features are exported such as column merging ExportOverwrite Sets the mode for ExportOverwriteMessage Sets the message to be displayed as warning to overwrite a file ExportRTFCell When true, grid cells with rich text are also exported as rich text, otherwise the cell text is exported without the rich text attributes. ExportShowInWord When true, MS Word is automatically opened with the exported RTF file
Delphi project & source files for downloading included in the main demos distribution for Delphi.
The project and source files have been written with Delphi 6,7. To use these files in other versions of Delphi, ignore any remarks when opening the form files and save the files. After this, compilation can be done. The error messages are due to properties included in the Delphi 6 form file, but not available in lower versions of Delphi.