Menu

Tree [r1] /
 History

HTTPS access


File Date Author Commit
 DbfExporter 2006-05-20 somalezu [r1]
 DbfExporterTests 2006-05-20 somalezu [r1]
 Specificatii 2006-05-20 somalezu [r1]
 DbfExporter.sln 2006-05-20 somalezu [r1]
 build.bat 2006-05-20 somalezu [r1]
 default.proj 2006-05-20 somalezu [r1]
 readme.txt 2006-05-20 somalezu [r1]

Read Me

DbfExporter
Version : beta

DbfExporter is a simple library that would export data from any .Net language to dbf (DBase III/ FoxPro 2.6) file format. 

Requirements
- .Net Framework 2.0 (we are using generics, but the code could be easily modified and ported to .net 1.0 / 1.1
- No need for any ODBC drivers or 3rd party components - we are writing direct in binary format using System.Io streams.

Typical usage : 
Define a class/structure that would specify the needed dbf file structure using ExportAsxxxColumn attributes :

public struct Record
{
private string _employeeName;
[ExportAsCharacterColumn("Name", 25)]
public string EmployeeName
{
	get{return _employeeName;}
	set{_employeeName = value;}
}

private decimal _tax;
[ExportAsNumericColumn("Tax",10,2)]
public decimal Tax
{
	get{return _tax;}
	set{_tax = value;}
}

}

Create an instance of the DbfExporter class, add rows and export to a dbf file :

DbfExporter<Record> exporter = new DbfExporter<Record>();
Record firstRow = new Record();
firstRow.EmployeeName = "Tudor";
firstRow.Tax = 12.5m;
exporter.Rows.Add( firstRow);
exporter.ExportToFile(@"C:\test.dbf");

Supported dbf columns types : Numeric,Character, Date and Logical

We have defined several complex attributes to facilitate export to fully denormalized files : 

- ExportAsCharacterColumnArray,ExportAsNumericColumnArray 
Exemple : 
private decimal[] _monthlyPayments = new decimal[12];
[ExportAsNumericColumnArray("Mnt_{Month}", "Month", 12, 10,2)]
public string[] MonthlyPayments
{
        get { return _monthlyPayments; }
}

This would export the _monthlyPayments array as a set of 12 numeric columns, Each of these columns would have 10 digits (2 decimals), named like this : Mnt_1, Mnt_2, Mnt_3...., Mnt_12 

- ExportByContent would export properties having some complex types (user defined class or struct). 
Example :
public class MarriedEmployee
{
private string _employeeName;
[ExportAsCharacterColumn("Name",25)]
public string EmployeeName
{
get{return _employeeName;}
}

private Wife _wife;
[ExportByContent(typeof(Wife))]
public Wife Wife
{
get{return _wife;}
}
}

public struct Wife
{
private string _socialSecurityNumber;
[ExportAsCharacterColumn("WIFE_SSN", 13)]
public string SocialSecurityNumber
{
get{return _socialSecurityNumber;}
}
private string _name;
[ExportAsCharacterColumn("Wife_Nam", 25)]
public string Name
{
get{return _name;}
}
}



- ExportByContentArray - would export array of user defined types a sets of basic dbf columns. 

Known issues : 
1. The order of the exported columns is given by the order of properties definitions in the Row structure. You should pay attention when defining the template of the row. I am investigating some way to specify the order in a more explicit form.
2. No support for less freqvent data types like Picture, Memo...