Defined-name lookups by name should be case-insensitive
Created originally on Bitbucket by mattsoptus (MattS)
In openpyxl/workbook/defined_name.py
there is currently a class DefinedNameList
that represents a set of Excel defined names, with several methods (get
, delete
etc) that operate on such defined names by their string name.
Each of these methods looks up the defined name using a case-sensitive ==
comparison. Thus, a call to workbook.defined_names.get("FooBar")
will not retrieve the defined name with name FoObAr
.
According to this brief note hidden within the Excel online documentation, defined names' names are case-insensitive:
https://support.office.com/en-us/article/names-in-formulas-fc2935f9-115d-4bef-a370-3aa8bb4c91f1
Additionally, when I define a formula in LibreOffice Calc for Linux that refers to a defined name using the defined name’s exact, case-sensitive name, then use OpenPyXL to read the resulting spreadsheet file, the formula that I read out of that cell contains the defined name’s name in all uppercase. I know of no way to defeat this unrequested case conversion by LibreOffice Calc.
Since the Excel documentation says names are case-insensitive, and since at least one implementation (LibreOffice Calc) changes the case of defined names' names in ways that seem difficult for the user to defeat, I think the code in openpyxl/workbook/defined_name.py that deals with such names should do so case-insensitively.