我如何找到了答案
我不知道的Excel的功能。因此,我將單元格A1命名爲cat
並保存該文件。我通過rar文件提取文件。在xl/workbook.xml
中發現了cat
,來源內容爲<definedName name="cat">工作表1!$A$1</definedName>
。這是一個名爲definedName
的元素,其屬性爲name
,其內容由工作表的title
和單元格coordinate
組成。所以該函數被稱爲defined name
或相關的東西。我發現它在official doc
回答
from openpyxl import load_workbook
wb = load_workbook(filename="test.xlsx")
# get DefinedNameList instance
defined_names_cat = wb.defined_names['cat']
# get destinations which is a generator
destinations_cat = defined_names_cat.destinations
values = {}
for sheet_title, coordinate in destinations_cat:
values.update({sheet_title: wb[sheet_title][coordinate].value})
my_value = values.get('Sheet1')
是「貓」別名用於特定小區(例如,A1)或整個工作表Sheet? - 什麼是excel相當於參考? –
'cat'是Excel中單元格的別名,座標'A1'等於'cat'。 –
你不明白'alias'是什麼意思。如果您的意思是某種定義的名稱,那麼這些是工作簿常量。 –