logo
small logo
  • Products
  • Buy
  • Support
  • Articles
  • Customer panel Support
    • en
    • ru
    • pt
    • es
    • de
    • pl
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to create a file in the Microsoft Word 2007 XML format from Delphi/C++Builder/Lazarus
  • How to make a PDF from Delphi / C++Builder / Lazarus

    May 14, 2020

    Quite often, you need to get a PDF document from a Pascal application - either

    read more
  • How to generate ITF (interleaved, industrial, matrix) barcode with Delphi / Lazarus / C ++ Builder

    November 11, 2020

    A bit of theory about barcodes It is difficult to imagine our life without barcodes, especially

    read more
  • Make Drill-Down report in FastReport VCL (Delphi/Lazarus)

    February 9, 2021

    "Drill Down" or "deepening into data" is a concept with many sides, which can refer

    read more
  • How to combine multiple reports into one PDF file in Delphi / Lazarus / C++ Builder

    September 3, 2020

    It is often necessary to combine several documents into one (for example, PDF). It could

    read more
  • Creating an Open Documents Spreadsheet from Delphi / C++Builder / Lazarus

    August 3, 2020

    Summary of ODS and ODF ODS is an open format for spreadsheets made in accordance with

    read more

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

June 10, 2020

DOCX is an archive file that can be unpacked by a third-party program. This format is an upgraded version of the well-known DOC extension. A significant difference is a low file weight while maintaining all the original image parameters. If .doc is a binary text file, .docx contains XML files and additional folders when the file compression reduces its size.

This is a universal format that can easily be read by almost any email client, cloud storage and text editors on your mobile device.
You can use the following programs to work with docx: WindowsWord, Libre Office, Open Office, Word Pad, AiReader, Ice Book Reader, Caliber, Universal Viewer, Text Maker, Ability Write. This is just a small list of the huge number of programs that can open files in DOCX format.

I wrote in more detail about XML in “How to export a report to Excel XML from Delphi / Lazarus ” article. But how do you create a file in the DOCX format from Delphi or Lazarus? Using FastReport!

Saving in .docx format from Delphi without writing a single line of code!

Setting Microsoft Word 2007 XML

First of all, add TfrxReport and TfrxDOCXExport (export to Microsoft Word 2007 XML) components on the form. Then create a report template in the designer, generate a report, click on Save in the preview window and call export from the preview (below I will describe how to save in DOCX format using a Delphi code). The window with export to DOCX settings will appear.

Although there are not many settings, it’s worth talking about them. First of all, we can choose which pages of our document to export to Word – certain pages or a range.


Setting Microsoft Word 2007 XML

As usual, you can specify where to save your DOCX file (in the local storage, send by e-mail, upload to FTP or cloud).


Open after export: the resulting file will be opened immediately after export by any software associated with these files. 



 

How to save in DOCX format directly from Delphi / Lazarus using a code

Saving to Microsoft Word 2007 XML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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}
 frxDOCXExport1.PageNumbers := '2-3';
 {Set whether to open the resulting file after export}
 frxDOCXExport1.OpenAfterExport := False;
 {Set whether to display export progress
  (show which page is currently being exported)}
 frxDOCXExport1.ShowProgress := False;
 {Set whether to display the export filter settings dialog box}
 frxDOCXExport1.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}
 frxDOCXExport1.FileName := 'C:\Output\test.docx';
 {Export the report}
 frxReport1.Export(frxDOCXExport1);
end;

Nothing complicated, as usual.

about product download buy
avatar
Michael Philippenko
CEO
VCL Lazarus FastReport 6 Delphi Word

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Buy
  • Download
  • Documentation
  • Testimonials
  • How to uninstall
  • Ticket system
  • FAQ
  • Tutorial Video
  • Forum
  • Articles
  • Our News
  • Press about us
  • Resellers
  • Our team
  • Contact us

© 1998-2021 by Fast Reports Inc.

  • Privacy Policy