OFiller demo

Create a template XLSX document with the name ofiller-test.xlsx and add the text #NAME into some cell. Then run this code:
procedure TForm1.Btn1Click(Sender: TObject);
var
  xOFiller: TCustomOFiller;
begin
  xOFiller := TOFillerXLSX.Create;
  try
    xOFiller.LoadFromFile(docDir+'ofiller-test.xlsx');

    //replace text tags
    xOFiller.ReplaceText('#NAME', 'Ondrej Pokorny');

    //replace image
    xOFiller.ReplaceImagesBegin;
    xOFiller.ReplaceImage('LOGO', docDir+'mylogo.png', srImageSetHeight, 147/45);
    xOFiller.ReplaceImagesEnd;

    xOFiller.SaveToFile(docDir+'ofiller-test-out.xlsx');
  finally
    xOFiller.Free;
  end;
end;
You can fill XLS, XLSX, DOCX, ODS and ODT templates. The usage is always the same. Use these classes:
  • for XLSX files: TOFillerXLSX
  • for XLS files: TOFillerXLS
  • for DOCX files: TOFillerDOCX
  • for ODS files: TOFillerODS
  • for ODT files: TOFillerODT
You can replace images only in the following files: XLSX, DOCX, ODS and ODT (not XLS).
Categories