logo
small logo
  • Products
  • Buy
  • Support
  • About
  • Customer panel Support
    • en
    • de
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • Creating an Open Documents Spreadsheet 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 create a ZPL file in Delphi/ C++ Builder/Lazarus

    December 22, 2020

    What is a ZPL file? ZPL stands for Zebra Programming Language. It allows team to

    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

    read more
  • How to create CODE 39 and CODE 39 Extended barcodes

    October 23, 2020

    CODE 39 is the barcode developed by Intermec Corporation in 1975. Up to 43 characters

    read more
  • How to combine multiple reports into PDF file in Delphi

    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 the OpenDocument Format (ODF) standard. This format is distributed free of charge and uses the standards of the International Organization for Standardization. The standard was developed by OASIS technical committee and was based on the XML format; it was approved for release as an ISO and IEC International Standard under the name ISO/IEC 26300 on May 1, 2006. NATO made the Open Document Format (ODF) standard mandatory to support interoperability among the various national governments. Many countries have adopted ODF as a state standard.

ODF spreadsheets (one of the varieties of ODS) are simple, interactive files objects used to analyze, organize, and store all kinds of spreadsheet-based data.

ODS resources can be opened with any modern office suite, OpenOffice, LibreOffice Suite and MS Office (since 2007).

Since 2014, the ODF standard has been added to the Google Docs, Sheets, and Slides web applications. Now you can open, edit and save files with the .odt (text documents), .ods (spreadsheets) and .odp (presentations) extensions. On Android phones and tablets, the most comprehensive support of ods files is implemented in the AndrOpen Office application.

Each ODF document is stored in a zip archive, therefore, to open this document, it is enough to rename its extension to .zip and open it with any zip archiver. After that we will see at least five .xml files and several directories.

There is so-called metadata in these xml files, in addition to the actual content of the document. It is the additional data that allows you to set specific parameters for the text. For example, font type and size, text position on the page, print or display options.

The XML metadata description standard (eXtend Markup Language) is gaining the most popularity nowadays. The main requirement of this standard is being user-friendly: xml documents should be easily readable using the simplest word processors and xml-markup should be simple to understand by a person.

ODF is one of numerous implementations of the XML standard. Therefore, after opening the ODF document as a ZIP archive, it won’t be a big deal to understand the structure of files and folders by their names. Especially for those who at least once in their life created html pages, at least at the same level of “Hello, World!” stuff. Content.xml is the main content file and style.xml contains the style information. Folders can contain multimedia files: pictures, audio and video. In general, the ODF document is something like a web site from the times of static html pages.

Now we learned about the format itself, but how do we save a report with the .ods extension? In fact, it’s extremely easy. We can create the simplest document and unzip it, as mentioned above. Let me remind you that the standard is open. Or… we can do it our favorite way!

Saving in .ODS format from Delphi using FastReport

Before saving an .ods file, you should already have a compiled project with FastReport implemented with the Export to Open Documents Spreadsheet component, as well as the generated report (there is a separate article on creating repots). Let me remind you again – yes, you can use internal sources of the application and databases as a data source for your report. Run the application and call export from the preview window (at the end of this article there is a way how to save the .ODS file directly from the code), a settings window will appear:

  

FastReport tools allow you to choose which pages of our document to export, certain pages or a range.

Export settings – whether to set a better visual correspondence with the original version (WYSIWYG), use page breaks, export as a continuous document that skips headers and footers, or export a background – graphic objects, that are used as a background of the report page.

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

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

Full code for saving in Open Document Spreadsheet format directly from Delphi / Lazarus

Saving to ODS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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}
 frxODSExport1.PageNumbers := '2-3';
 {Set whether to generate a continuous document}
 frxODSExport1.SingleSheet := False;
 {Set whether to export the page breaks so that when printing the pages correspond to the pages of the generated report}
 frxODSExport1.ExportPageBreaks := True;
 {Set WYSIWYG}
 frxODSExport1.Wysiwyg := True;
 {Set whether to export the background}
 frxODSExport1.Background := True;
 {Set whether to open the resulting file after export}
 frxODSExport1.OpenAfterExport := False;
 {Set whether to display export progress (show which page is currently being exported)}
 frxODSExport1.ShowProgress := False;
 {Set whether to display the export filter dialog box}
 frxODSExport1.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}
 frxODSExport1.FileName := 'C:\Output\test.ods';
 {Export the report}
 frxReport1.Export(frxODSExport1);
end;

So, quickly and easily we can make our application to generate modern global format files. 

about product buy
avatar
Michael Philippenko
VP
Fast Reports Team: Michae Philippenko - VP at Fast Reports
VCL Export Lazarus FastReport Delphi

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
  • FAQ
  • Tutorial Video
  • Forum
  • Articles
  • Our News
  • Press about us
  • Resellers
  • Extended licensing
  • Contact us

© 1998-2023 by Fast Reports Inc.

  • Privacy Policy