简体   繁体   English

从大型Excel文件中获取工作表名称

[英]Getting sheet names from a large Excel file

I am using Python 3.7 and using OpenPyxl to read the sheet names from a large excel workbook (29MB) with 10 tabs. 我正在使用Python 3.7并使用OpenPyxl从一个包含10个选项卡的大型excel工作簿(29MB)中读取工作表名称。

import openpyxl
from openpyxl import load_workbook
wb = load_workbook(filename='h:\\Master_Portfoliio.xlsx')
print(wb.sheetnames)

The code above works for smaller files but when I use the same code for this file, the code just hangs. 上面的代码适用于较小的文件,但是当我对此文件使用相同的代码时,代码就会挂起。 I would like to read the sheet names and then remove a tab and then copy a tab from another excel workbook into this workbook. 我想阅读工作表名称,然后删除一个选项卡,然后将另一个Excel工作簿中的选项卡复制到此工作簿中。

你试过read_only = True标志吗?

wb = load_workbook(filename='h:\\Master_Portfoliio.xlsx', read_only = True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM