Search code examples
delphidelphi-2010

Using Delphi to fill out a table template made using a rich text (rtf) file


I have a table in rtf (rich text format) file format.

I wonder if it is possible to place different content into the cells at runtime.

Here is a screenshot. Some blank fields need to be filled in with a value.

screenshot


Solution

  • You wrote "Some blank fields need to be edited" - if this means that the RTF is some kind of template, where empty fields need to be filled in programmatically, here is what I would do:

    • use your text editor to open the RTF document (OpenOffice or MS Word for example)
    • insert special placeholder strings in the empty fields like $field1$, $field2$ ...
    • save the document
    • in your Delphi application, load the RTF into a string (using TStringlist for example)
    • use Delphi String functions to find and replace the special placeholder strings with the actual values