基于VBA CodeName属性读取Excel工作表

2024-10-02 10:22:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个.xls Excel文件,并且知道要读取的工作表的VBA CodeName属性。如何使用工作表的CodeName属性而不是Name属性将工作表读入Python?你知道吗

讨论VBA代码名和名称之间差异的主题:Excel tab sheet names vs. Visual Basic sheet names


Tags: 文件代码name名称主题属性names差异
1条回答
网友
1楼 · 发布于 2024-10-02 10:22:13
#you have to install the module
#import the xlrd module
import xlrd
workbook = xlrd.open("example.xls") #it can take x|xs|xls format
#if you know the name of the sheet use
sheet = workbook.sheet_by_name("name of the sheet")
#or you can use index number
sheet = workbook.sheet_by_index("index of the sheet here")
#you can print the cell you want like this
print(" print from the 4th row 2nd cell".format(sheet(4,2).value))

如果这是有用的,给它一个像如果不是我不理解英语很好,谢谢你,我是新的

相关问题 更多 >

    热门问题