I'm trying to load an existing workbook using openpyxl. But when I'm trying to run this code - I'm getting following error:
AttributeError: 'module' object has no attribute 'load_workbook'
import openpyxl
works fine, what I'm doing wrong?
Create a workbook ¶ There is no need to create a file on the filesystem to get started with openpyxl. Just import the Workbook class and start work: >>> from openpyxl import Workbook >>> wb = Workbook()
The same way as writing, you can use the openpyxl.load_workbook () to open an existing workbook:
If you want to save the file to a stream, e.g. when using a web application such as Pyramid, Flask or Django then you can simply provide a NamedTemporaryFile (): You can specify the attribute template=True, to save a workbook as a template:
The examples are for a later version of openpyxl
. In 1.1.4 the main __init__.py
did not provide a shortcut to load_workbook
in the form of
from openpyxl.reader.excel import load_workbook
so you will have to do that instead of:
from openpyxl import load_workbook
what is shown in the example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With