FastReport: How to create a file in the Microsoft PowerPoint 2007 XML format from Delphi/C++Builder/Lazarus

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009
FastReport: How to create a file in the Microsoft PowerPoint 2007 XML format from Delphi/C++Builder/Lazarus
July 27, 2020 by Michael Philippenko
[SHOWTOGROUPS=4,20,22]
Microsoft PowerPoint is a program for preparing and viewing presentations. It is a part of Microsoft Office and is available in editions for Microsoft Windows and macOS operating systems, as well as for Android and iOS mobile platforms.

The program saves new presentations in * .pptx, * .ppt, * .ppsx and * .pps formats. From time to time the question arises - how to make a presentation in Delphi / Lazarus?
There are not so many options.
1. Learn about PPTX and write directly in this format. Honestly, it’s a dubious pleasure. But you will learn many interesting things. :)
2. Struggle with OLE, having MS Office installed on your working computer.
3. Or choose an alternative – for example, FastReport!

FastReport allows you to immediately see and check your document before exporting it to PowerPoint. There are so many options for changes, from barcodes (yes, those QR codes on slides that can send your audience to the website, give your business card, ask to vote etc.!) to charts and cards with pictures.

Let’s create a PowerPoint presentation from Delphi / Lazarus using FastReport designer

As usual, we will need only TfrxReport component on the form and a button with a handler.
Код:
procedure TForm1.Button1Click(Sender: TObject);
begin
 {Generate a report. The report must be generated before exporting}
 if frxReport1.PrepareReport then
 frxReport1.ShowPreparedReport;
 {and show preview window}
end;

Create a document of any kind, size and content, which will become our presentation!
Oh, and don’t forget to add TfrxPPRXExport on the form. Launch, check and save in PPTX format from the preview window.

Save to Microsoft PowerPoint 2007 XML


Click on the Save icon in the upper left corner. Here we can see more than ten options for export to the required format.

In this case, we need to save in the Microsoft PowerPoint 2007 XML file format, so click on it.

Setting Microsoft PowerPoint 2007 XML


Now, in the appeared window we can see the document export settings.

Here you can save all the pages, the current page or a range.

There is also the open after export function.

Setting Microsoft PowerPoint 2007 XML


And the possibilities do not end there. In FastReport VCL you can save the file in the local storage, upload it to the cloud or send it by e-mail. Finally, click on the Save button.

We’ve covered how to write a report in the Microsoft PowerPoint 2007 XML file format from Delphi / C++Builder / Lazarus from the preview window.

Saving in the Microsoft PowerPoint 2007 XML file format from Delphi or Lazarus code
Код:
procedure TForm1.Button1Click(Sender: TObject);
begin
 {Generate a report. The report must be generated before exporting}
 frxReport1.PrepareReport();
 {Set the range of pages to export. By default, all pages of the generated report are exported}
 frxPPTXExport1.PageNumbers := '2-3';
 {Set in what format to export your images}
 //uses frxImageConverter;
 // TfrxPictureType = (gpPNG, gpBMP, gpJPG {$IFNDEF FPC}, gpGIF, gpEMF, gpWMF{$ENDIF})
 frxPPTXExport1.PictureType := gpPNG;
 {Set whether to open the resulting file after export}
 frxPPTXExport1.OpenAfterExport := False;
 {Set whether to display export progress
  (show which page is currently being exported)}
 frxPPTXExport1.ShowProgress := False;
 {Set whether to display the export filter settings dialog box}
 frxPPTXExport1.ShowDialog := False;
 {Set the name of the resulting file.}
 {Please note that if you do not set the file name and disable the export filter dialog box,}
 {the file name selection dialog will still be displayed}
 frxPPTXExport1.FileName := 'C:\Output\test.pptx';
 {Export the report}
 frxReport1.Export(frxPPTXExport1);
end;

As you can see, it is easy to create presentations from Delphi or Lazarus. Of course, there are some limitations – graphics and maps from the presentation will become images and the beautiful effects such as “appear”, “dissolve” and the other objects behavior will need to be configured in the presentation making program.
[/SHOWTOGROUPS]