The example in this article describes how Python exports dbf files to Excel. Share to everyone for your reference. Specific as follows:
From dbfpy import dbffrom time import sleepfrom win32com import clientdef dbf2xls (Dbfilename, exfilename): db = dbf. DBF (Dbfilename, True) ex = client. Dispatch (' Excel.Application ') wk = ex. Workbooks.Add () ws = wk. ActiveSheet Ex. Visible = True sleep (1) r = 1 c = 1 for field in Db.fieldnames: ws. Cells (R,C). Value = Field c = c+1 r = 2 for record in db: c = 1 for field in Db.fieldnames: ws. Cells (R,C). Value = Record[field] c = c+1 r = r+1 wk. SaveAs (exfilename) wk. Close (False) ex. Application.Quit () db.close () if __name__== ' __main__ ': dbffilename = "test.dbf" xlsfilename = " Text.xls " Dbf2xls (Dbffilename, Xlsfilename)
Hopefully this article will help you with Python programming.