Difference between revisions of "fpdbfexport"

From Free Pascal wiki
Jump to navigationJump to search
(→‎Example: link to dbtestframework examples)
 
(13 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
{{fpdbfexport}}
 
== Overview ==
 
== Overview ==
The fpdbfexport module is part of the FreePascal FCL database modules.
+
=== FPC ===
This export module provides export to DBF formats (e.g. DBase IV format). This format is still popular because it is simple, and - opposed to e.g. csv - is clear about what data type is enclosed in its fields.
+
The fpdbfexport module is part of [[fpDBExport]] in the FreePascal FCL database modules.
 +
 
 +
This export module provides export to DBF formats (e.g. DBase IV format). The format is still fairly popular because it is simple, and - opposed to e.g. [[CSV]] - is clear about what data type is enclosed in its fields.
 
Many spreadsheet and database programs can import DBF files.
 
Many spreadsheet and database programs can import DBF files.
 +
 +
=== Lazarus ===
 +
In Lazarus, the DBF export component is located on the ''Data Export'' tab.
 +
 +
[[File:DataExportTab.png]]
  
 
== Limitations and known bugs ==
 
== Limitations and known bugs ==
In FPC 2.6.2 (e.g. supplied with Lazarus 1.0.8), exporting to e.g. dbase IV format - that has a 10 character field length limit - of fields with longer field names will throw an error unless you populate the export fieldname mapping yourself.
+
In FPC before 2.6.4/Lazarus before 1.2.2, exporting to e.g. dbase IV format - that has a 10 character field length limit - of fields with longer field names will throw an error unless you populate the export fieldname mapping yourself.
 
 
This bug has been fixed in FPC trunk revision 24490
 
See [http://bugs.freepascal.org/view.php?id=24423]
 
  
 
== Example ==
 
== Example ==
 
See the examples in your FPC source directory $(fpcdir)\source\packages\fcl-db\tests (see [[Databases#Running_FPC_database_tests]]), specifically testdbexport.pas.
 
See the examples in your FPC source directory $(fpcdir)\source\packages\fcl-db\tests (see [[Databases#Running_FPC_database_tests]]), specifically testdbexport.pas.
  
The various export formats are run in TestDBFExport_DBaseIV, TestCSVExport etc.
+
The various export formats are run in  
 +
* TestDBFExport_DBaseIV  
 +
* TestDBFExport_DBaseVII
 +
* TestDBFExport_FoxPro
 +
* TestDBFExport_VisualFoxpro
 +
etc.
  
 
The procedure TTestDBExport.GenericExportTest shows how you can export to only supported field types (handy if you do not know in advance what field types are used in a dataset).
 
The procedure TTestDBExport.GenericExportTest shows how you can export to only supported field types (handy if you do not know in advance what field types are used in a dataset).
  
[[Category:Databases]]
+
Another useful example is the the dbftool example included in FPC 2.6.4+:
[[Category:FPC]]
+
* creating DBF files
 +
* using DBF files
 +
* exporting data (to DBF and other formats) using db export
 +
 
 +
The source is also downloadable via http://svn.freepascal.org/svn/fpc/trunk/packages/fcl-db/examples/
 +
 
 +
== See also ==
 +
* [[Lazarus Tdbf Tutorial]] Tutorial and documentation on TDBF, the DBF support in FPC SQLDB (which is also used in Lazarus). Link to official TDBF documentation.
 +
* [[fpDBExport]]
 +
* [[fpXMLXSDExport]] Similar module that exports to various XML formats.
 +
<br/>

Latest revision as of 13:14, 30 June 2017

English (en) français (fr)

Overview

FPC

The fpdbfexport module is part of fpDBExport in the FreePascal FCL database modules.

This export module provides export to DBF formats (e.g. DBase IV format). The format is still fairly popular because it is simple, and - opposed to e.g. CSV - is clear about what data type is enclosed in its fields. Many spreadsheet and database programs can import DBF files.

Lazarus

In Lazarus, the DBF export component is located on the Data Export tab.

DataExportTab.png

Limitations and known bugs

In FPC before 2.6.4/Lazarus before 1.2.2, exporting to e.g. dbase IV format - that has a 10 character field length limit - of fields with longer field names will throw an error unless you populate the export fieldname mapping yourself.

Example

See the examples in your FPC source directory $(fpcdir)\source\packages\fcl-db\tests (see Databases#Running_FPC_database_tests), specifically testdbexport.pas.

The various export formats are run in

  • TestDBFExport_DBaseIV
  • TestDBFExport_DBaseVII
  • TestDBFExport_FoxPro
  • TestDBFExport_VisualFoxpro

etc.

The procedure TTestDBExport.GenericExportTest shows how you can export to only supported field types (handy if you do not know in advance what field types are used in a dataset).

Another useful example is the the dbftool example included in FPC 2.6.4+:

  • creating DBF files
  • using DBF files
  • exporting data (to DBF and other formats) using db export

The source is also downloadable via http://svn.freepascal.org/svn/fpc/trunk/packages/fcl-db/examples/

See also

  • Lazarus Tdbf Tutorial Tutorial and documentation on TDBF, the DBF support in FPC SQLDB (which is also used in Lazarus). Link to official TDBF documentation.
  • fpDBExport
  • fpXMLXSDExport Similar module that exports to various XML formats.