唠唠啊 发表于 2019-12-19 08:39:52

module 'openpyxl' has no attribute 'load_wordbook'

wb = openpyxl.load_wordbook(r'D:\SYSTEM\MSO-LYL\Desktop')
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
    wb = openpyxl.load_wordbook(r'D:\SYSTEM\MSO-LYL\Desktop')
AttributeError: module 'openpyxl' has no attribute 'load_wordbook'

满脸问号。。。难道是版本问题?

冬雪雪冬 发表于 2019-12-19 08:55:38

workbook

唠唠啊 发表于 2019-12-19 09:11:56

wb = openpyxl.load_workbook(r"D:\SYSTEM\MSO-LYL\Desktop\办公篇.xls")
Traceback (most recent call last):
File "<pyshell#23>", line 1, in <module>
    wb = openpyxl.load_workbook(r"D:\SYSTEM\MSO-LYL\Desktop\办公篇.xls")
File "C:\Users\YLLiu\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openpyxl\reader\excel.py", line 312, in load_workbook
    reader = ExcelReader(filename, read_only, keep_vba,
File "C:\Users\YLLiu\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openpyxl\reader\excel.py", line 124, in __init__
    self.archive = _validate_archive(fn)
File "C:\Users\YLLiu\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openpyxl\reader\excel.py", line 94, in _validate_archive
    raise InvalidFileException(msg)
openpyxl.utils.exceptions.InvalidFileException: openpyxl does not support the old .xls file format, please use xlrd to read this file, or convert it to the more recent .xlsx file format.

唠唠啊 发表于 2019-12-19 09:17:47

。xls版本太老不支持么

唠唠啊 发表于 2019-12-19 09:22:22

冬雪雪冬 发表于 2019-12-19 08:55
workbook

{:10_277:} 这问题问的太随意了

gywjj 发表于 2019-12-19 13:19:53

根据提示,是不支持,要用xlrd.open_workbook(filename[, logfile, file_contents, ...])打开

参天小草 发表于 2019-12-19 14:17:15

唠唠啊 发表于 2019-12-19 09:17
。xls版本太老不支持么

openpyxl不支持xls,要先转化一下。单个文件可以直接另存为xlsx,批量的话网上有VBA代码
页: [1]
查看完整版本: module 'openpyxl' has no attribute 'load_wordbook'