albfernandez / javadbf

Java library for reading and writing Xbase (dBase/DBF) files.
GNU Lesser General Public License v3.0
224 stars 98 forks source link

Add option to disable extended (2-byte length) character fields #64

Closed cursor42 closed 4 years ago

cursor42 commented 4 years ago

We used the old JavaDBF library created by Anil Kumar to read DBF data for a long time and are planning to switch to your fork now.

Some time ago, MS-EXCEL was able to read and write DBF data (current versions can only read). So we have several files, where users used EXCEL to edit DBF data.

Unfortunately, EXCEL was not writing the DBF format correctly. We experienced the following:

DBFField.adjustLengthForLongCharSupport() added support for 2-byte length character fields (which was a 'hack' of some old PC programs).

This leads the DBFReader to crash because it now expects a large number of characters (520 in the example above).

I implemented a simple boolean flag to be able to turn off this 'feature' so that we can read mangled MS-EXCEL files without the support for the 'Clipper and FoxPro' data formats.

Please see column 'FLUGHOEHE' in the example DBF attached (which is read correctly by LibreOffice, for example):

wrong-exented-character-field.zip

albfernandez commented 4 years ago

Thanks!