Pavel Lisiza
Pavel Lisiza

Reputation: 131

can't load workbook with openpyxl

I'm trying tu use openpyxl to open excel-files with python. It already worked but suddenly it doesn't. I successfully installed openpyxl. I can import openpyxl but I am not able to use any functions of this module.

import openpyxl
wb = openpyxl.load_workbook('sampletable.xlsx')

result: AttributeError: 'module' object has no attribute 'load_workbook'

second example:

from openpyxl import Workbook
result: ImportError: cannot import name 'Workbook'

I am using openpyxl 2.4.0. on Python 2.7.13 interpreter and openpyxl 2.4.7. on Python 3.4.3.

Upvotes: 3

Views: 7232

Answers (2)

ismail
ismail

Reputation: 175

you must import load_workbook

from openpyxl import load_workbook
wb=load_workbook("sampletable.xlsx")

Upvotes: 0

Arthur D. Howland
Arthur D. Howland

Reputation: 4557

Use:

from openpyxl import load_workbook

"import openpyxl" does not seem to work for loading existing workbooks.

Upvotes: 3

Related Questions