1
我想使用python將.dbf文件轉換爲.xls。我引用這個snippet,但我不能得到的第一個非標題行使用此代碼來寫: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")
我怎樣才能獲得的第一個非標題行寫?
謝謝
這給了我以下錯誤:異常:嘗試覆蓋細胞:SHEETNAME = u'Sheet 1' rowx = 0 colx = 0 – artwork21 2013-03-04 14:27:21
好的我得到了你的更新,thx! – artwork21 2013-03-04 14:37:58