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.

1

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.