xlrd excel表读取错误“open_workbook()得到一个意外的关键字参数'on_demand'”“

时间:2013-04-30 01:19:53

标签: python xlrd

我正在使用xlrd从excel表中读取单元格值。我的代码如下,它之前工作正常,但不知道xlrd包中有什么变化,我收到了错误

“TypeError:open_workbook()得到了一个意外的关键字参数'on_demand'”

from xlrd import open_workbook
bench = open_workbook('excelsheet.xls',on_demand=True)
for name in bench.sheet_names():
    sheetnew = bench.sheet_by_name(name)
    for i in range(0, 13):
        for cell in sheetnew.col(i):
            print cell.value
    bench.unload_sheet(name)

1 个答案:

答案 0 :(得分:0)

这解决了我的问题。可能对某人有帮助。

from xlrd import open_workbook
bench = open_workbook("excelsheet.xls")
for name in bench.sheet_names():
    sheetnew = bench.sheet_by_name(name)
    for i in range(0, 13):
        for cell in sheetnew.col(i):
            print cell.value