我如何找到了答案
我不知道的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'是什么意思。如果您的意思是某种定义的名称,那么这些是工作簿常量。 –