如何在 ODS 文件中获取 sheet 名称?
How to get a sheet name in an ODS file?
我看到有两个库可以使用:pyexcel_ods3
和 pyexcel_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'
你能帮帮我吗?
您可能在安装时出错。
检查您同时拥有 pyexcel
和 pyexcel-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']
请注意,在您的示例中,您试图直接在 pyexcel_ods
模块上调用 get_book
和 Sheet
,而我只导入 pyexcel
(并且有安装了 ods 模块)并且它可以正常工作,pyexcel 在打开 .ods 文件时自动找到该模块。
我看到有两个库可以使用:pyexcel_ods3
和 pyexcel_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'
你能帮帮我吗?
您可能在安装时出错。
检查您同时拥有 pyexcel
和 pyexcel-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']
请注意,在您的示例中,您试图直接在 pyexcel_ods
模块上调用 get_book
和 Sheet
,而我只导入 pyexcel
(并且有安装了 ods 模块)并且它可以正常工作,pyexcel 在打开 .ods 文件时自动找到该模块。