'commit'
This commit is contained in:
BIN
Doc/数据库-2015-2024-v2.xlsx
Normal file
BIN
Doc/数据库-2015-2024-v2.xlsx
Normal file
Binary file not shown.
23
Tools/GetJson.py
Normal file
23
Tools/GetJson.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# 读取 Doc目录 数据库-2015-2024-v2.xlsx 文件内容
|
||||||
|
# pip install openpyxl
|
||||||
|
|
||||||
|
import openpyxl
|
||||||
|
file_name=r'D:\dsWork\YunNanProject\Doc\数据库-2015-2024-v2.xlsx'
|
||||||
|
|
||||||
|
# 读取Excel文件并获取所有sheet名称
|
||||||
|
try:
|
||||||
|
# 加载工作簿(添加密码参数)
|
||||||
|
workbook = openpyxl.load_workbook(file_name, read_only=True)
|
||||||
|
sheet_names = workbook.sheetnames
|
||||||
|
|
||||||
|
print("Excel中的sheet名称列表:")
|
||||||
|
for idx, sheet in enumerate(sheet_names, 1):
|
||||||
|
print(f"{idx}. {sheet}")
|
||||||
|
|
||||||
|
# 关闭工作簿释放资源
|
||||||
|
workbook.close()
|
||||||
|
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(f"错误:找不到文件 '{file_name}'")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"读取Excel时发生错误:{str(e)}")
|
0
Tools/__init__.py
Normal file
0
Tools/__init__.py
Normal file
Reference in New Issue
Block a user