1

我看到有两个库可以使用:pyexcel_ods3pyexcel_ods. 我试着用

pyexcel_ods.Sheet("file.ods") 

pyexcel_ods.get_book(file_name="file.ods") 

但我得到了这些错误:

AttributeError: module 'pyexcel_ods' has no attribute 'Sheet'

AttributeError: module 'pyexcel_ods' has no attribute 'get_book'

你可以帮帮我吗?

4

1 回答 1

1

您可能在安装时出错了。

检查您是否同时拥有pyexcelpyexcel-ods

pip install pyexcel pyexcel-ods

试试下面的代码:

from pyexcel import get_book

sheet = get_book(file_name="file_example_ODS_10.ods")
print(sheet)

(您可以在此处获取有效的示例文件https://file-examples.com/index.php/sample-documents-download/sample-ods-download/

要获取名称:

from pyexcel import get_book

sheet = get_book(file_name="file_example_ODS_10.ods")
print(sheet.sheet_names())

结果:

['Sheet1']

请注意,在您的示例中,您试图直接调用模块,get_book而我只导入(并安装了 ods 模块)并且正常工作,pyexcel 在打开 .ods 文件时会自动找到该模块。Sheetpyexcel_odspyexcel

于 2020-06-07T22:16:50.213 回答