我想使用 python 将 .dbf 文件转换为 .xls。我已经引用了这个代码片段,但是我无法使用此代码编写第一个非标题行:
from xlwt import Workbook, easyxf
import dbfpy.dbf
dbf = dbfpy.dbf.Dbf("C:\\Temp\\Owner.dbf")
book = Workbook()
sheet1 = book.add_sheet('Sheet 1')
header_style = easyxf('font: name Arial, bold True, height 200;')
for (i, name) in enumerate(dbf.fieldNames):
sheet1.write(0, i, name, header_style)
for row in range(1, len(dbf)):
for col in range(len(dbf.fieldNames)):
sheet1.row(row).write(col, dbf[row][col])
book.save("C:\\Temp\\Owner.xls")
如何获得要写入的第一个非标题行?
谢谢