尝试应用xlrd来处理xls文件,但是一开始就失败了

尝试使用xlrd来处理xls文件,但是一开始就失败了我的平台是Eclipse+Python 2.7 并且安装了xlrd-0.6.1.win32

尝试使用xlrd来处理xls文件,但是一开始就失败了
我的平台是Eclipse+Python 2.7 并且安装了xlrd-0.6.1.win32
#!/usr/bin/env python
#-*- coding:gbk-*-
'''

'''


import xlrd
#from pyExcelerator import *

   
if __name__ == '__main__':
  book = xlrd.open_workbook('E:\handle_excel\src\e_1.xlsx')
  print "The number of worksheets is", book.nsheets
  print "Worksheet name(s):", book.sheet_names()
  sh = book.sheet_by_index(0)
  print sh.name, sh.nrows, sh.ncols
  print "Cell D30 is", sh.cell_value(rowx=29, colx=3)
  for rx in range(sh.nrows):
  print sh.row(rx)


以下是错误
Traceback (most recent call last):
  File "E:\handle_excel\src\handle_excel_001.py", line 12, in <module>
  book = xlrd.open_workbook('E:\handle_excel\src\e_1.xlsx')
  File "D:\Python27\lib\site-packages\xlrd\__init__.py", line 370, in open_workbook
  biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
  File "D:\Python27\lib\site-packages\xlrd\__init__.py", line 1323, in getbof
  raise XLRDError('Expected BOF record; found 0x%04x' % opcode)
xlrd.biffh.XLRDError: Expected BOF record; found 0x4b50

[解决办法]
xlrd 是不能读取 2007的excel文件的。

如果需要处理2007格式的excel文件,推荐使用 http://packages.python.org/openpyxl/