اینم یه روش از سایت foxite
خودم تا حالا تست نکردم
برای انجام این کار اکسل باید روی سیستمتون نصب باشه
*------------------------------------------------------------------------
* ut_RepairDBF()
*
* Call this routine to repair a DBF file reported by VFP to be corrupted.
*
* PASSES:
* tcFile = The full path to the DBF file to be repaired.
* e.g. 'c:\path\table.dbf'
*
* RETURNS:
* .t. if successful, .f. otherwise.
*
* OUTPUT:
* The original DBF is backup with .bak extension.
* The repaired DBF has the same name as the original file.
*
* EXAMPLE:
* ut_RepairDBF('c:\path\table.dbf')
*
* REMARKS:
* Microsoft Excel is used to repair the DBF.
*------------------------------------------------------------------------
function ut_RepairDBF(tcFile)
local loExcel as Excel.Application
local lcBackupFile
local lcFixedFile
if empty(tcFile) or not file(tcFile)
return .f.
endif
loExcel = createobject("Excel.Application")
if vartype(loExcel)<>'O'
return .f.
endif
lcBackupFile = alltrim(tcFile)+'.bak'
lcFixedFile = alltrim(tcFile)+'.tmp'
delete file (lcBackupFile)
delete file (lcFixedFile)
loExcel.Workbooks.Open(tcFile)
loExcel.ActiveWorkbook.SaveAs(lcFixedFile, xlDBF3)
loExcel.ActiveWindow.Close(.f.)
loExcel.Quit()
rename (tcFile) to (lcBackupFile)
rename (lcFixedFile) to (tcFile)
endfunc