0

I try to insert value into Excel files with Python and xlrd module as follow:

import xlrd
data=xlrd.open_workbook('1.xls')       
table=data.sheets()[0]
row = 0
col = 0
ctype = 1 # 类型 0 empty,1 string, 2 number, 3 date, 4 boolean, 5 error
value = 'abc'
xf = 0 # 扩展的格式化 (默认是0)
table.put_cell(row, col, ctype, value, xf)

but no new data 'abc' in the Excel file. So anyone helps? Thanks ahead.

Baoqger Bao
  • 19
  • 2
  • 4
  • Have a look at http://stackoverflow.com/questions/2725852/writing-to-existing-workbook-using-xlwt/2726298#2726298 – George May 17 '13 at 11:48

1 Answers1

3

xlrd is for reading. You need xlwt if you want to write.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • I just find this point about xlwt. Now I can use xlwt to insert data into a new Excel file, but how to insert data into an exiting file? Still need more suggestion. Thanks a lot. – Baoqger Bao May 17 '13 at 11:36