0
我有一個.xls Excel文件,並且知道要讀取的工作表的VBA CodeName屬性。我如何使用工作表的CodeName屬性將工作表讀入Python,而不是它的Name屬性?基於VBA CodeName屬性讀取Excel工作表
主題討論VBA代號和名稱的區別:Excel tab sheet names vs. Visual Basic sheet names
我有一個.xls Excel文件,並且知道要讀取的工作表的VBA CodeName屬性。我如何使用工作表的CodeName屬性將工作表讀入Python,而不是它的Name屬性?基於VBA CodeName屬性讀取Excel工作表
主題討論VBA代號和名稱的區別:Excel tab sheet names vs. Visual Basic sheet names
#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))
,如果這是有益的給它一個像如果不是我不懂英語好三江源和我是新
這隻能說明如何通過名稱或索引訪問工作表,而不是通過其「CodeName」。 (例如,工作表的「CodeName」可能是'shtInputData',它的'Name'可能是''Input'',其索引可能是'3'。) – YowE3K